1 страниц (5 вхождений)
How to input a group of matrix use for loop - matrix operation - Сообщения
#1 Опубликовано: 29.04.2021 01:34:21
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 Опубликовано: 29.04.2021 01:59:20
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 Опубликовано: 29.04.2021 03:14:11
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 Опубликовано: 29.04.2021 08:04:10
#5 Опубликовано: 29.04.2021 11:05:37
1 страниц (5 вхождений)
-
Новые сообщения
-
Нет новых сообщений