Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hi,
Herewith, I have attached the problem (mcdx file) that I am having trouble with.
I have a vector C with 105 elements in it
I have another function x(y) with 'y' varying from 0 to 1 with a stepsize of 0.001 (Vector with 1000 elements in it)
I want to find out which value of 'y' would give the resulting value of 'x' which matches the element in C. Therefore, I need to create a matrix M3 (105 Elements) with 'y' that was found out before for that particular value of C and x.
For example The first element in C is 0.184. The y value 0.635 results in x = 0.184, matching C. So the first element of my M3 matrix is 0.635.
Please refer to the attached MATHCAD file for the problem.
Thank You!
While I didn't spend a lot of time on it, I don't think your approach will work. Basically because of errors - You are looking at specific intervals and hoping they match up with the C value. They won't unless you specifically round them off to a few digits. But that's a poor way of doing it anyway. You can solve the equation directly (4 possible answers, 1 seems to match your example so I went with it). Then a simple solve block and a program to call it for each row. See PDF.
The function "match" gives you the ability to modify.
I can't open your file (I'm stuck at Prime 3.0), but have you tried
DX[i := match(C[i,Y,X,"near") ??
You say you're working with vectors, but you are not.
M1 = x is a range (from 0.8, in steps of 0.05 up to 5.
With all the calculation that follows, the result is that the value C that you want to find a 'y' value for is also a range.
If you restructure your sheet to use functions and/or real vectors (stuff that you can access individual elements of by indexing) it becomes very easy to find 'y' value for any given x-value through the difinition of C, namely:
i:=0,1...105
M3[i:=root(C(y)-x[i,y,0.8,5)
Where it is assumed that C is defined as a function of y: C(y).
I leave it up to you to change the worksheet; the way it is structured now makes it difficult for me to discern what are constants, what are functions and what are results of those functions.
If you have problems after that, don't hesitate to come back (in this same thread).
Success!
Luc