Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi All,
Is there an easier way to convert a range variable into a vector? That is, suppose we have a list of data (perhaps huge) in a single table over a range. Infact, this range variable is the output of a part of programming in mathcad. How to convert this in to a vector? Once I can convert this into a vector, then I can easily locate roots using curve "fitting".
If you have a range variable, say i:=0:10, you can create the vector x with values 0 to 10 simply by x[i:=i (where the '[' symbol provides a subscript in Mathcad - it's a pity the text formatting in these posts doesn't allow subscripts given the frequency with which they're used in Mathcad).
Alan
Alan Stevens wrote:
it's a pity the text formatting in these posts doesn't allow subscripts given the frequency with which they're used in Mathcad).
Alan
Alan,
Just one of many problems with the website. It surely isn't hard to implement subscript/superscript formatting options.
Image attached.
Mike
Suppose the range variable is as follows:
For i:=1...4, we have f(i):= 0.001, 0.0019,0.0025, 0.0031
I would like to convert these four values of f(i) into a single vector, say "g". Note that I don't want to copy each value and type it over and over.
Ashehad
Ashehad Ali wrote:
Suppose the range variable is as follows:
For i:=1...4, we have f(i):= 0.001, 0.0019,0.0025, 0.0031
I would like to convert these four values of f(i) into a single vector, say "g". Note that I don't want to copy each value and type it over and over.
Ashehad
Why can't you simply create a vector of the required values?
How are the values for "f" found?
Mike
I've managed to work out. I don't know what was the error though. Writing f subscript i and equating it to f(i). Then computing f gives me the vectorised form, so simple. It didn't use to give me before, however.
Ashehad Ali wrote:
I've managed to work out. I don't know what was the error though. Writing f subscript i and equating it to f(i). Then computing f gives me the vectorised form, so simple. It didn't use to give me before, however.
Its seems you're going round the houses to get your answer.
You could post a worksheet so other collabs will offer a different approach.
Mike
Ashehad Ali wrote:
I've managed to work out. I don't know what was the error though. Writing f subscript i and equating it to f(i). Then computing f gives me the vectorised form, so simple. It didn't use to give me before, however.
You shouldn't, in general, re-use the function name (f) as the new vector's name(also f). It is much better to use a different name for the results vector, so that after you have created the vector you can still use the function (by its name). It is easy to start getting lots of 'error messages' when mathcad (or is that you;-) is getting confused as to which version of 'f' it is using.
Because mathcad is a functional style language, you can pass not only strings, scalars, vectors and matrices to functions, but you can also pass functions by name into functions. This can be amazingly powerful, but does leave one open to forgetting that you can't have the same name for more than one thing at a time.
If you do wish to re-use names, then look up the "MathStyles", which are 8 differentiating tags for names, and can have differentiating formattiong to go with them. Unfortunately they lack good shortcuts so are rarely used.
Philip
Ashehad Ali wrote:
Suppose the range variable is as follows:
For i:=1...4, we have f(i):= 0.001, 0.0019,0.0025, 0.0031
I would like to convert these four values of f(i) into a single vector, say "g". Note that I don't want to copy each value and type it over and over.
Ashehad
Simple:
g[i := f(i)
Have you deleted your other thread ?
Possibly answered [generally] here:
http://communities.ptc.com/message/152316#152316
jmG
jean Giraud wrote:
Have you deleted your other thread ?
Possibly answered [generally] here:
http://communities.ptc.com/message/152316#152316
jmG
Jean,
That link doesn't seem to be working.
The link to the other thread is below.
http://communities.ptc.com/thread/32637
Mike
MIke Armstrong wrote:
jean Giraud wrote:
Have you deleted your other thread ?
Possibly answered [generally] here:
http://communities.ptc.com/message/152316#152316
jmG
Jean,
That link doesn't seem to be working.
The link to the other thread is below.
http://communities.ptc.com/thread/32637
Mike
Yes, broken link was reported many times.
Not acknowledged is not correct, simply !
Jean
Here's the file which I have been working with that kind of stimulated the discussion of this subject. The data in the table F corresponds to functions f and g, which are outcomes of a part of a programming. f and g behave as "log" and "exponents", respectively. See the graph. I'm not confident with the root which I've got. I think it's the curves that I fitted are incorrect. Could someone improve the root by using alternative fitting perhaps? Just noting that the vectors v1 and v2 are parameters for the guess estimates of log and exponentials.
Cheers,
Ashehad
Plot the fits and the points together on the same graph. By eye they look reasonable in the region where they cross (i.e. near the root). However, you haven't specified the accuracy you want, so it's difficult to say if the result is good enough.
Alan
Use spline interpolation rather than fitting a function to the data.
Thanks Richard.
"g" looks exponential,but not of the traditional forms.
jmG
Jean,
You are certainly right. I didn't know if there was any other alternative to fitting as suggested by Richard.
Ashehad