1
$\begingroup$

I've only been using MMA for a month, and I'm working on making interactive Linear Algebra examples that will be used online for students. Right now, for inputting numbers into a matrix, I've been using PopupMenu since it is simple to use and more stable then InputField for my application.

I currently just manually enter an array of PopupMenus:

inputA = {{PopupMenu[Dynamic[a11], Range[-9,9]],PopupMenu[Dynamic[a12], Range[-9,9]],PopupMenu[Dynamic[a13]}, {PopupMenu[Dynamic[a21], Range[-9,9]],PopupMenu[Dynamic[a22], Range[-9,9]],PopupMenu[Dynamic[a23]}, {PopupMenu[Dynamic[a31], Range[-9,9]],PopupMenu[Dynamic[a32], Range[-9,9]],PopupMenu[Dynamic[a33]}}; 

One downside to PopupMenu is that it is too "cluttered" when the Range is too large. I haven't found any better ways of inputting values, but I was wondering if anyone had suggestions for alternatives for inputting values.

Also, is there is a more concise way of coding in MMA for making this input array?

$\endgroup$
9
  • $\begingroup$ Would it be an option to just let them type 2D input as normal, using Control-Enter and Control-Comma? The problem is that they need to know how to do this ... $\endgroup$ Commented Jun 29, 2016 at 19:14
  • $\begingroup$ Concise way: Clear[a]; Array[ (a[##] = 1; PopupMenu[Dynamic[a[##]], Range[-9, 9]]) &, {3, 3}] // MatrixForm, then use the matrix as Array[a, {3,3}], e.g. display it as Dynamic@MatrixForm@Array[a,{3,3}] $\endgroup$ Commented Jun 29, 2016 at 19:18
  • $\begingroup$ @Szabolcs your concise version will work perfectly, thank you! Also, I think I'll just stick to the current input method since there will be a decent amount of usage (students throughout USA) and that could cause more problems $\endgroup$ Commented Jun 29, 2016 at 19:28
  • $\begingroup$ Can you tell more about why you find InputFields unstable? $\endgroup$ Commented Jun 29, 2016 at 20:19
  • $\begingroup$ @Kuba I (recent mech. engineering grad) inherited this project from a Computer Science guy in the company who used InputField initially, but when he input fractions or just erased what was inside the field, the rest of the application would break. So he told me to use PopupMenu instead, and I kind of just assumed he knew what he was talking about. It is highly possible that he was just missing something (like Number) but I never actually took the time to check since I was brand new to the language. $\endgroup$ Commented Jun 30, 2016 at 12:15

1 Answer 1

2
$\begingroup$

This Exemple calculate Dynamicly a Determinant with PopupMenu:

{MatrixForm[Array[(a[##]=0; PopupMenu[Dynamic[a[##]],Range[0,9]])&,{3,3}]], Dynamic[d=Table[Table[a[j,i],{i,1,3}],{j,1,3}];Det[d]]} 

enter image description here

Useful for students

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.