cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Using results from output of function

JL_10781440
7-Bedrock

Using results from output of function

Vers: MathCAD Prime 7.0.0.0
See screen grab attached.
I'm not that hot on mathcad so excuse the lack of termiknowledge.

Essentially I've created a function which outputs a 'list' of values I then go on to change the input values producing new 'lists'.

I would then like to evaluate the first value of each list against the others, however, I believe the 'lists' need to be any of; an array, a vector or a matrix. Which I'm assuming they're not going by B[1]= failing to return a value.


My attempts to convert them have failed: (units are not compatible)
As you can see at the moment I've just typed out the first value of the 'list'.
Any help is appreciated.

Cheers,
J

 

 

ACCEPTED SOLUTION

Accepted Solutions

Ok so I've found that if I define my original range as equal to a new variable it becomes a vector or array. This then means my output becomes a vector/array I can then pull values from it.

 

Which if you ask me is stupid all I'm doing is typing z:=x and z is now a vector/array where x wasn't.
Screenshot 2023-09-13 111142.png

View solution in original post

5 REPLIES 5
LucMeekes
23-Emerald III
(To:JL_10781440)

I like your 'termiknowledge'  !

But: Please attach your Prime worksheet, not just a picture.

Further: You need to understand the difference between a range and a vector.

You've created z as a range. And while the result of B(z) looks like a vector, it is not, so you cannot index it.

 

Success!
Luc

 

For some info on range <> vector see here: https://community.ptc.com/t5/Mathcad/How-to-form-a-matrix-with-variables-defined-with-range/m-p/891020#M207928

Hi Luc

As shown in my own reply all I needed to do was redefine my z range as any other variable and all was gravy.

LucMeekes
23-Emerald III
(To:JL_10781440)

Yep, gravy.

But bear in mind that you are now using an undocumented trick. It may become supported functionality, or become non-functional in a future version of Prime.

 

Success!
Luc

Ok so I've found that if I define my original range as equal to a new variable it becomes a vector or array. This then means my output becomes a vector/array I can then pull values from it.

 

Which if you ask me is stupid all I'm doing is typing z:=x and z is now a vector/array where x wasn't.
Screenshot 2023-09-13 111142.png

Werner_E
25-Diamond I
(To:JL_10781440)

 

The (undocumented) trick to turn a range (which is kind of an implicit loop and not a set of values)  into a vector is not the re-assignment to another variable but the inline evaluation immediately after the definition in the same region. If you would defined x:=0,R/10..R = then x would have been a vector right away.

The trick exists for a very long time (even back in older versions of real Mathcad) but as its undocumented its a matter to be changed without notice. So while its quite convenient, it may be a good idea not to rely on it in important worksheets which are supposed to have a long life span.

Announcements

Top Tags