Skip to main content
6-Contributor
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_E
Werner_EAnswer
25-Diamond I
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

Werner_E
25-Diamond I
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.

Translate
thodij6-ContributorAuthor
6-Contributor
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

Translate
Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
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

Translate
SPaulis
14-Alexandrite
Mar 4, 2026 5:45 PM UTC

@thodij try this

 

 

Screenshot 2026-03-04 104422.png

 

Translate
"It's OK to fall in love with your heart, but you design with your head." Omer W. Blodgett
SPaulis
14-Alexandrite
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

Translate
"It's OK to fall in love with your heart, but you design with your head." Omer W. Blodgett
thodij6-ContributorAuthor
6-Contributor
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

 

Translate