Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate the entire conversation x

The value must be scalar or a matrix issue using range to create values for plotting

DJ_12857440
4-Participant

The value must be scalar or a matrix issue using range to create values for plotting

I'm not able to understand, what's causing the error when I create a range. Please review and guide, next step would be plotting with the values. 

Using Mathcad 10

DJ_12857440_0-1739024786221.png

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:DJ_12857440)

Don't use the vector index "i" at m.air (or use it at m.air AND Th2)

Werner_E_0-1739060488642.png

BTW, I am not good in inventing names for variables - you sure can find better names for "collectLMTDcntf", etc. 😉

 

View solution in original post

10 REPLIES 10
Werner_E
25-Diamond I
(To:DJ_12857440)

Its hard up to impossible to debug a picture.

If ever possible always attach the worksheet itself.

 

In your case the reason for the error seems to be that you did not consider the difference between a range and a vector.

A range is just kind of an implicit loop, its NOT a collection of various values!

 

Her one way to define m.air as vector, not as range (assuming that ORIGIN is at its default value 0)

Werner_E_0-1739026878688.png

Note that the "i" is a vector/matrix index, not a literal index as "air".

 

Ranges should only be used for three reasons:

  • To index the elements of a vector/matrix (as in the example above)
  • To form a for-loop in a program
  • To make the abscissa in a plot

 

Remark: Up to version Prime 9 we could convert easily a range into a vector using an undocumented trick. PTC promised to provide a "legal" way to do so in Prime 11.

Here in the forum you will find user-defined functions which turn a range into a vector and also function which create a vector with a sequence of values by providing the first, second and last value (similar to the range definition).

 

Some additional comments:

As Th2 would be a vector as well, chances are that you have to vectorize the function call to F_CrossFlowHX...

When displaying the result of the difference of two temperates given in °C, you should not use °C but rather Delta°C (equivalent to Kelvin).

Werner_E_1-1739027698911.png

 

 

DJ_12857440
4-Participant
(To:Werner_E)

Apologies, if I missed to attached worksheet on my post. Please see attached worksheet.
I tried using your example, but still have error. 

Werner_E
25-Diamond I
(To:DJ_12857440)

You did not write a vector index i when defining m.air but rather renamed the variable in mi.air.

And when you call the function F_CrossFlowHX... you have to use vectorization (the arrow over the expression) to apply the function to every element in he vector.

As your function return a 2x5 matrix, you get a nested vector with 26 elements, each of which is a 2x5 matrix.

When you talked about plotting in your initial post - did you had something like this in mind?

Werner_E_0-1739030032879.png

 

See the attached worksheet.

 

DJ_12857440
4-Participant
(To:Werner_E)

Hi,

 

I was able to understand your suggestion, now i'm running into a issue. Can you please review and recommend how I can get the correct plot.

 

Plot Th2 vs mair

Plot F vs mair

Plot U vs mair.

 

Attached worksheet.

Werner_E
25-Diamond I
(To:DJ_12857440)

Don't use the vector index "i" at m.air (or use it at m.air AND Th2)

Werner_E_0-1739060488642.png

BTW, I am not good in inventing names for variables - you sure can find better names for "collectLMTDcntf", etc. 😉

 

DJ_12857440
4-Participant
(To:Werner_E)

Thank you, I didn't pay attention to how it sounded. In my head it's was counter flow 😁..

DJ_12857440
4-Participant
(To:Werner_E)

Can you please check if this step correct is on the worksheet, please see below image

DJ_12857440_0-1739064621855.png

 

Werner_E
25-Diamond I
(To:DJ_12857440)


@DJ_12857440 wrote:

Can you please check if this step correct is on the worksheet, please see below image

DJ_12857440_0-1739064621855.png

 


Depends on what exactly you want to calculate 😉

collectLMTDcorr and collectF are 7x1 vectors, so their product is calculated as vector product (scalar product) and thats the reason the result is just a single value.

If you want the calculation to be done element-wise and the result should again be a 7x1 vector, you have to vectorize the calculation

Werner_E_0-1739066697060.png
Werner_E_1-1739066829213.png

 

Werner_E
25-Diamond I
(To:Werner_E)

I am not sure if you need the vectors you defined.

It look to me that you are just interested in how the various quantities are dependent on m.air.

So it may be more useful to turn your calculations into functions of the variable m.air.

That way you can evaluate any value (R, F, LMTD.corr, etc.) for any input value of m.air immediately and your plots look continuous as you can use a range variable (just for plotting) with a small step width.

 

BTW, is there a special reason why in your plots you placed the independent variable m.air at the ordinate and not the abscissa?

 

Werner_E_0-1739105098444.png

 

Of course, if you need vectors of values (maybe for a table) you can always define an input vector and call these functions vectorized with this vector as their argument.

Werner_E_0-1739105846337.png

DJ_12857440
4-Participant
(To:Werner_E)

Hi Werner,

Thank you for reviewing and provide your comments. I was able to get the answer for my plot, now on to next problem and will bring new issues for review, 😀

Announcements

Top Tags