Skip to main content
6-Contributor
February 26, 2026
Solved

Programming construct with for & if-then loop

  • February 26, 2026
  • 2 replies
  • 109 views

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

Best answer by Werner_E

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

2 replies

25-Diamond I
February 26, 2026

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.

thodij6-ContributorAuthor
6-Contributor
February 26, 2026

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_E25-Diamond IAnswer
25-Diamond I
February 26, 2026

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-Alexandrite
March 4, 2026

@thodij try this

 

 

Screenshot 2026-03-04 104422.png

 

14-Alexandrite
March 4, 2026

@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

thodij6-ContributorAuthor
6-Contributor
March 4, 2026

SPaulis -

 

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

Awesome PTC community!

 

Regards,

thodij