Skip to main content
Feb 26, 2026 8:03 PM UTC
Solved

Programming construct with for & if-then loop

Hi PTC Community,

I am not sure why this programming construct will not work: apply the Nu function on a scalar & a column vector.

 

I use Mathcad Prime 11.0.1.0.

 

Thanks,

thodij

Werner_EAnswer
Feb 26, 2026 8:47 PM UTC

And why is you function using the vector Re? It seems to be useless.

And why isn't it using its argument x??

 

So you are just looking for something like this?

grafik.png

You may also use

grafik.png

14 replies

Feb 26, 2026 8:26 PM UTC

Which results do you expect in case of argument 99 and argument Re.l ?

Your function does not use its argument x at all. So the result would be the same for whatever argument you provide.

The error stems from the fact that you can't compare a vector with a scalar (Re<50).

But I don't see what the goal of your function should be.

thodijAuthor
Feb 26, 2026 8:36 PM UTC

I see that Nu(99) is not covered in the logic ranges! Need to add another else if 50 <= Re < 100 in the logic.

 

For Rel = [49 200 230 300], I would expect Nu(Rel) = [0.25 0.50 0.50 0.75]

 

Thanks,

thodij

Werner_EAnswer
Feb 26, 2026 8:47 PM UTC

And why is you function using the vector Re? It seems to be useless.

And why isn't it using its argument x??

 

So you are just looking for something like this?

grafik.png

You may also use

grafik.png

Mar 4, 2026 5:45 PM UTC

@thodij try this

 

 

Screenshot 2026-03-04 104422.png

 

Mar 4, 2026 5:48 PM UTC

@Werner_E covered most of this already. 

 

I guess I only added the updated program that handles both single item and arrays automatically, without vectorization

thodijAuthor
Mar 4, 2026 6:04 PM UTC

SPaulis -

 

I appreciate your taking the time to offer this additional/ more general solution.

Awesome PTC community!

 

Regards,

thodij