1

I would like to store a column of a matrix to a list, whose name is stored in a string. How can one do this?

What I am primarily attempting to do is use a loop to create various lists in which columns of a matrix can be stored. To do this, I am using a for loop and concatenating the "list prefix" with the number, which is then stored in a string. However, when I try to use the Matrlist() command, it does not accept the string as a legitimate list name. Is there a way to override this?

χ²-Test([A],[B])
[B]-[A]→[C]

dim([A])→MD1
⌊MD1(2)→K

For(A,1,K,1)
{0,1}→L₁
{0,A}→L₂
LinReg(ax+b) Y₁
EquString(Y₁,Str1)
sub(Str1,1,length(Str1)-3)→Str)
"EO"+Str1→Str1
Matrlist([C],A,Str1)
End

For(A,1,K,1)
{0,1}→L₁
{0,A}→L₂
LinReg(ax+b) Y₁
EquString(Y₁,Str1))
sub(Str1,1,length(Str1)-3)→Str1
"E"+Str1→Str1
Matrlist([B],A,Str1)
End

Listmatr(⌊EO1²/⌊E1,⌊EO2²/⌊E2,⌊EO3²/⌊E3,[D])
"⌊EO4²/⌊E4,⌊EO5²/⌊E5,⌊EO6²/⌊E6,⌊EO7²/⌊E7,⌊EO8²/⌊E8,⌊EO9²/⌊E9)

SetUpEditor

Disp [D]
Diafotismos
  • 109
  • 1
  • 10
  • I don't have a calculator anymore to try this on, but I believe you just assign to the list and it will be created. – Jonathon Reinhart Feb 26 '16 at 01:44
  • Ah, I just realized that I had accidentally submitted the "how to automatically add lists" question instead of this one. Would you perhaps happen to know a way to do this (see above for updated question)? – Diafotismos Feb 26 '16 at 03:38

1 Answers1

1

You can't create a reference to a list from a string.

In general, there is no way to store anything to a dynamically selected variable. The expr( command can evaluate a list whose name is in a string, but cannot return an lvalue.

In your case, the problem of doing element-wise division on two matrices can be solved by augmenting a new column vector onto matrix [D] in a loop: something like

χ²-Test([A],[B])
[B]-[A]→[C]

dim([A])→MD1
⌊MD1(2)→K

Matr►list([B],1,L1
Matr►list([C],1,L2
List►matr(L1/L2,[D]    //first column

For(A,2,K)
Matr►list([B],A,L1
Matr►list([C],A,L2
List►matr(L1/L2,[E]
augment([E],[D]→[D]    //other columns
End

SetUpEditor

Disp [D]

The separate code for the first column is required since empty matrices cannot be created.

Community
  • 1
  • 1
lirtosiast
  • 592
  • 4
  • 15