Matrix from variablesIf I defined variables
a=5;
b=3;
what is the fastest/most elegant way to get?
m = [5,3]
Is there something better than
m= Matrix(Eval({a,b}));And why does
m=[Eval(a),Eval(b)]
not work?
Any links to related posts are welcome 
Advanced Statistical ModelingConsumer and Market ResearchDesign of ExperimentsRe: Matrix from variablesWhat do you think about
a=5;
b=3;
m=matrix(a) |/b //-> works !?!
a combination of all riddles in one expression 
Re: Matrix from variablesIt's amazing that
[](0,1) |/ a |/ b
works. That means, it automatically evaluates the arguments and converts them into a matrix?
a= {{5,3}}
b = {{7 ,6}}
[](0,2) |/ a |/ b
While sharing my learning with my colleagues I noticed:
Up to now, I thought that [a, b] is just a short form of the constructor matrix({a,b}).
But it's the result, right?
Now I really understand what you mean::
@ErraticAttack wrote:
you cannot put expressions in the matrix elements
Then the examples in my last post don't make sense. They just don't work because the matrix() function doesn't have a function to set non-numerical values to "." (missing) - compare the original topic.
By the way:
I am a bit surprised to see the result of matrix(3). Kind of an easter egg ?
Re: Matrix from variablesOK understood.Thanks a lot for the explanation.
@ErraticAttack wrote:
you cannot put expressions in the matrix elements and expect that it will be populated with the number returned by that expression.
Is a good wording 
It could work but you cannot expect that it will work:
a=5;
matrix(a/b); // -> works<BR />matrix(char(a)) // -> doesn't
matrix({char(a)}) // --> doesn't (I hoped this could be a workaround ...)</CODE></P><P><FONT face="arial,helvetica,sans-serif"><CODE class=" language-jsl">So ..
@ErraticAttack wrote:
Expressions are strictly _not_ allowed in matrices, only numbers are allowed.
seems to be slightly too strict - but a good approach "to be on the safe side"
</CODE></P><P> </P></LINGO-BODY><LINGO-SUB id="lingo-sub-594389" slang="en-US" mode="NONE">Re: Matrix from variables</LINGO-SUB><LINGO-BODY id="lingo-body-594389" slang="en-US" mode="NONE"><P>Using <CODE class=" language-jsl">Matrix( {a, b} ) is probably the easiest way. One way that I use commonly is [](0,1) |/ a |/ b
</CODE></P><P>As for your second question, matrices are special in JSL and are not evaluated as you would expect. Normally you can put a JSL expression anywhere in the JSL script and only the final argument would get returned. However, with matrices (probably for the code to be more optimized and speedy), you cannot put expressions in the matrix elements and expect that it will be populated with the number returned by that expression. Expressions are strictly _not_ allowed in matrices, only numbers are allowed. This is also why variables don't work within matrices, as variables only make sense when they are evaluated as an expression.</P></LINGO-BODY><LINGO-SUB id="lingo-sub-594089" slang="en-US" mode="NONE">Re: Matrix from variables</LINGO-SUB><LINGO-BODY id="lingo-body-594089" slang="en-US" mode="NONE"><P>oh, Matrix evaluates the list? got it!</P><P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1674830940841.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_0-1674830940841.png" style="width: 400px;"><span class="lia-inline-image-display-wrapper" image-alt="hogi_0-1674830940841.png" style="width: 400px;"><img src="https://us.v-cdn.net/6038925/uploads/images/49532i15A375331B9C81B2/hogi_0-1674830940841.png" role="button" title="hogi_0-1674830940841.png" alt="hogi_0-1674830940841.png" /></span></SPAN></SPAN></P><P><BR />Then </P><PRE><CODE class=" language-jsl">m= Matrix({a,b});
works as well 
And what's the reason that
m=[Eval(a),Eval(b)]
doesn't work?
Re: Matrix from variablesFor me, the easiest way to get to the result is
m=matrix(a) |/ matrix(b);