Skip to main content
1-Visitor
June 13, 2024
Solved

For loop

  • June 13, 2024
  • 3 replies
  • 1584 views

I have defined function with "for loop" inside for table content processing. It looks simple, but unfortunately it doesn't work. Instead of calculation results , the message  "This value mus be a scalar a matrix" is being displayed.

I was using this function with Mathacad 15 and it was working fine, but I can't reproduce it within Mathcad Prime 8.

Where did I go wrong?

 

Regards,

Bogdan

Best answer by Werner_E

ttokoro already pointed you to the error.

You had an implicit multiplication between "(rows)" and "N.t.".

Werner_E_0-1718321442123.png

It should read "rows(N.t.)" instead!

Werner_E_1-1718321488969.png

Now you should get the expected result:

Werner_E_2-1718321563067.png

You can achieve the very same result without any utility function in one go using a boolean comparison and vectorisation

Werner_E_3-1718321606367.png

Another option is using a simpler utility function, written to be used with just one scalar and called vectorized.

Here are two example for that kind of utility function

Werner_E_0-1718322135229.png

 

 

 

3 replies

ttokoro
21-Topaz I
21-Topaz I
June 13, 2024

image.png  rows(Nt)

t.t.
18-Opal
June 13, 2024

Maybe try

ppal_0-1718316473348.png

 

Werner_E25-Diamond IAnswer
25-Diamond I
June 13, 2024

ttokoro already pointed you to the error.

You had an implicit multiplication between "(rows)" and "N.t.".

Werner_E_0-1718321442123.png

It should read "rows(N.t.)" instead!

Werner_E_1-1718321488969.png

Now you should get the expected result:

Werner_E_2-1718321563067.png

You can achieve the very same result without any utility function in one go using a boolean comparison and vectorisation

Werner_E_3-1718321606367.png

Another option is using a simpler utility function, written to be used with just one scalar and called vectorized.

Here are two example for that kind of utility function

Werner_E_0-1718322135229.png

 

 

 

1-Visitor
June 14, 2024

Thank you for all advices, issue is solved.

 

Regards,

Bogdan