The value must be scalar or a matrix issue using range to create values for plotting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
Solved! Go to Solution.
- Labels:
-
Mathcad Usage
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Don't use the vector index "i" at m.air (or use it at m.air AND Th2)
BTW, I am not good in inventing names for variables - you sure can find better names for "collectLMTDcntf", etc. 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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)
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Apologies, if I missed to attached worksheet on my post. Please see attached worksheet.
I tried using your example, but still have error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
See the attached worksheet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Don't use the vector index "i" at m.air (or use it at m.air AND Th2)
BTW, I am not good in inventing names for variables - you sure can find better names for "collectLMTDcntf", etc. 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thank you, I didn't pay attention to how it sounded. In my head it's was counter flow 😁..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Can you please check if this step correct is on the worksheet, please see below image
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@DJ_12857440 wrote:
Can you please check if this step correct is on the worksheet, please see below image
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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?
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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, 😀
