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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Create a vector from the result of a function

S00tt
1-Visitor

Create a vector from the result of a function

Hi

I have a MathCAD sheet that applies a function to a range variable.

e.g. t:= 0,0.001..1

x(t):=2 * t

How can I then convert x(t) into a vecor e.g Y:=x(t)

Thanks

Scott

ACCEPTED SOLUTION

Accepted Solutions

Something like the attached?

Mike

View solution in original post

21 REPLIES 21

Something like the attached?

Mike

Instead of using a range variable you could just create a range vector, see attached image.

Mike

Ninetrees
12-Amethyst
(To:S00tt)

How about

t:=0,0.001..1

Y[t*1000 := t*2

This works only because the range t is uniform...it would still work w non-uniform ranges, but not as you might expect...try w ranges as short as, say, 5, elements, and you will see what I mean...

~R~

Y[t*1000 := t*2

Do you mean Y[t*100?

This is a horrible way to go about it though, don't you think?

Mike

Well...I based my response on the original post...

e.g. t:= 0,0.001..1

x(t):=2 * t

which looks to me as if it is 1/1000 of the interval twixt 0 and 1. But I could be mistaken...at any rate, it is the technique that I am referencing...

~R~

Sorry Richard, my mistake.

Missed a zero.

Mike

Better to start with the integer iterator

n:=1;100

Then to create the vector

t[n:=n* x ms

It does give more options to be creative with the intervals,

t[n:= n^2 * x ms is just as valid

and no rounding errors to worry about

Andy

Thanks for all the tips. I know using a vector in the 1st place is an easier way to do things but this is a samll part of a much bigger sheet that requires a range variable.

I had to export the results to LabVIEW which requires a vector.


Thanks

As long as you've got your answer.

Mike

S00tt
1-Visitor
(To:Ninetrees)

I think I can use this...

S00tt
1-Visitor
(To:S00tt)

OK.

I dont quite have the answer Im looking for. I've already calculated everything and at the end of the sheet I have values for say x(t). I now need to convert x(t) into a vector. It's a big worksheet which isnt mine so cant change it much. I just need to x(t) in a vector form to transfer it to LabVIEW. t is a non-integer range variable.

Can you post the actual data?

t is a non-integer range variable.

Do you mean t is a non-uniform range variable?

Mike

Message was edited by: MikeArmstrong

Ninetrees
12-Amethyst
(To:S00tt)

Without the file, it is difficult to know what your limitations are...but in my original post, Y would have the values you seek. If the source is in Mathcad, and you want x(t) to contain the values of 0..1 in 0.001 steps, then you could simply write

x[t*1000 := 2*t

I agree with the other comments about making a vector and addressing rounding...

I'm not sure what your x(t) represents: is it your indication that you want an array/vector, or is it a Mathcad function that returns a list of values?

~R~

RichardJ
19-Tanzanite
(To:S00tt)

See the attached

AlvaroDíaz
12-Amethyst
(To:S00tt)

Scott Colston wrote:

OK.

I dont quite have the answer Im looking for. I've already calculated everything and at the end of the sheet I have values for say x(t). I now need to convert x(t) into a vector. It's a big worksheet which isnt mine so cant change it much. I just need to x(t) in a vector form to transfer it to LabVIEW. t is a non-integer range variable.

----------------

I don't understand very well. Do you "have values for say x(t)"? Are the set of values for x discrete? I beleve that you mean that "have a relationship for say x(t)". Assuming this, you want to convert x (the name of the function, not x(t)) into a vector of values (a discrete and representative collection -set- of values of x).

Collabs give you all the ways to do that. I use range variables very few times, just for some plots, and try to use it always as an integer counter.

To convert x in an exportable (to labview) vector can try using the attached, which don't use range variables.

Regards. Alvaro.

Alvaro,

I can not work with vectors instead range variables because I have a lot of functions depending of these range variables. After made calculations, I have a function results (with a lot of singularities) and I need find max and min values from these results. I need convert these results to a vector, so, I can use max and min functions to find the maximum and minimun values or export these values to Excel.

Do you have any solutions to this case?

You can download the file (Mathcad Prime 3) at link below.

https://drive.google.com/file/d/0B88zvUOMB4-ATHNpelhaa2NnLW8/edit?usp=sharing

Thank you.

RichardJ
19-Tanzanite
(To:JPMN)

Your functions do not depend on the range variables. The parameters b1 and h1 in the function definitions are formal parameters for those functions that tell Mathcad what to do when the function is called. They have nothing to do with the range variables you defined, which you can easily show by moving the range variable definitions. Here's how to find the maximum.

You can attach files to your post if you click on "Use Advanced Editor at the top right of the edit dialog.

Werner_E
25-Diamond I
(To:JPMN)

You seem to like jumping on old threads. You have already posted the same question here: http://communities.ptc.com/message/241734#241734

Please don't crosspost and open a new discussion if you have a question.

so if you can create a vector for the result of a function.

then you can use the max function to find the maximum. Will this be faster than doing a solve block

It might be faster, but it will certainly be much less accurate: onlly half the increment of the independent variable.

I work with a brute force scan for minimizing, but can't find it. An algorithm without derivatives -incomplete, just for working- can be found in http://communities.ptc.com/servlet/JiveServlet/download/135434-15924/minimize_parabolic_golden.mcd at http://communities.ptc.com/message/135438.

The method of searching extremas discretizing first and looking for the maximun is usual with matlab. This also provide absolute max or min, while the derivatives methods search for local extremas.

Regards. Alvaro.

Announcements

Top Tags