1 Pages (5 items)
How to input a group of matrix use for loop - matrix operation - Messages
#1 Posted: 4/29/2021 1:34:21 AM
I have say, 4 matrix, size of (nr, nz). I am trying to do initiation of these 4 matrix, vs, vb, Cs, Cb. In mathcad, you create a matrix of 4 column and 1 row, representing these 4 matrix, and initiate with for loop.

Smath didn't show any errors. But when I tried to display the values of one matrix, say, vs=, nothing show up.
I thought Smath might treat all variables as global variable, so, I tried anther way:

Then the error showed up, "requested matrix element doesn't exist".
Do I really have to create vs, vb, Cs, Cb before I initiate them?
It is a very simple problem, but I really need help.
By the way, the tutorial is slightly different from reality in "range". When I define for loop ranges, such as [for i "belong" 0..100], the tutorial shows using range2 to choose (0,100), the context will show as above, but the reality will show [for i "belong"[0..100]], a bracket was added. I hope I used the range function properly.
Thanks!

Smath didn't show any errors. But when I tried to display the values of one matrix, say, vs=, nothing show up.
I thought Smath might treat all variables as global variable, so, I tried anther way:

Then the error showed up, "requested matrix element doesn't exist".
Do I really have to create vs, vb, Cs, Cb before I initiate them?
It is a very simple problem, but I really need help.
By the way, the tutorial is slightly different from reality in "range". When I define for loop ranges, such as [for i "belong" 0..100], the tutorial shows using range2 to choose (0,100), the context will show as above, but the reality will show [for i "belong"[0..100]], a bracket was added. I hope I used the range function properly.
Thanks!
#2 Posted: 4/29/2021 1:59:20 AM
Hi. SMath matrix index starts at 1, not at 0. If you want to translate Mathcad code into SMath, try to use ORIGIN:=1 in Mathcad, because x[0] always gives an error in SMath.
Best regards.
Alvaro.
Best regards.
Alvaro.
#3 Posted: 4/29/2021 3:14:11 AM
WroteHi. SMath matrix index starts at 1, not at 0. If you want to translate Mathcad code into SMath, try to use ORIGIN:=1 in Mathcad, because x[0] always gives an error in SMath.
Best regards.
Alvaro.
Thanks a lot. Following your instructions, I started to initiate from 1, using the 2nd picture, instead of 0. It worked.
#4 Posted: 4/29/2021 8:04:10 AM
#5 Posted: 4/29/2021 11:05:37 AM
1 Pages (5 items)
-
New Posts
-
No New Posts