Ultimately, I am trying to compare a plot developed on MathCAD to some experimental results that have been processed in MATLAB.
Since I could not find a way to transfer data between the two, I thought to export both sets of data to Excel and plot them on top of each other there. I had no issue exporting the data from MATLAB. MathCAD Prime 4.0 however, is proving more difficult.
The plot was created using a range and expressions that refer to that range. I uploaded a sample code that demonstrates the issue.
It appears that I cannot use the excel component to write an expression based on a range, though I can write the range itself. Is there a way to transfer the values of my expression to a vector so that I can export to excel, without re-writing the previous expressions that lead up to my final expression?
Thanks
Solved! Go to Solution.
Use please not a range variable but a vector!
See please the attach
Thanks, but this is not the solution I was looking for. I asked:
Is there a way to transfer the values of my expression to a vector so that I can export to excel, without re-writing the previous expressions that lead up to my final expression?
The vector approach doesn't work for my calculations for a separate reason. If there is no way to achieve what I'm looking for here, then perhaps we can get into how to do matrix multiplication with elements that are built from vectors instead of ranges...
What your sheet suffers from is misuse of ranges.
Ranges should be used just for
1) define a range for plotting
2) index elements of vectors and matrices
3) for a for-loop in a program
In ALL other cases you have to use vectors, not range variables.
You may have already noticed that the results you get with your range fr are just for viewing. They are not valid Mathcad results and so you cannot even assign them to a variable.
As you can see in valery's sheet, the approach with fr as vector works fine and the results can be used for whatever you may like.
Why do you think that you cannot use a vector approach? Maybe you don't know about vectorization?
What exactly do you mean by "how to do matrix multiplication with elements that are built from vectors instead of ranges" ?
Thanks for your reply,
I understand this use of ranges is generally considered as a misuse, though prior to this I had no need of a vector with all the values, all I desired was the plot. I'm assuming when you say "they are not valid MathCAD results" you don't mean that the values shouldn't be trusted, but only that I can't assign them places.
I guess since it appears the answer is probably "no there isn't a way to do what you're asking without redefining the previous equations" it is worth exploring how I might re-define those equations with vectors. I've attach an example of the math I'm doing, which I don't understand how to accomplish with vectors in MathCAD.
Admittedly no, I don't know what vectorization will do for me, though reading the quick explanation from PTC support, maybe this is the piece I am missing to help simplify the attached math with vectors rather than ranges?
Thanks again
Thanks Werner,
Did you use Prime 5.0 to create this? It wont let me open on 4.0, says you saved in a more recent version. (How do you like 5.0? Big improvement?)
I assume you appended the section shown at the end, since you re-defined "i" and it didn't break the equations using the radical. I appended what you showed in the image to mine and it works the same as you depict, so I assume that is the only change.
Thank you for this example showing what vectorization will do for me, that actually makes the change very easy. Also thanks for the example on writeexcel, I had tried it previously but didn't know I could use "augment" like that.
@cgenger wrote:
Thanks Werner,
Did you use Prime 5.0 to create this? It wont let me open on 4.0, says you saved in a more recent version. (How do you like 5.0? Big improvement?)
Yes, the file was opened and saved in Prime 5.
And no, Prime 5 is no improvement at all. The only thing they added (maybe some bug fixes, too - there's no documentation of bug fixes in Prime like we were used with Mathcad) is a third party chart component which IMHO is just one big disappointment for various reason. I have ranted about it in several other threads here so I won't repeat it. Personally I don't like any version of prime and am still using Mathcad 15 for a while (and then will switch to other software as Mathcad is a dead end). I am just using Prime here in the forum to answer questions.
I assume you appended the section shown at the end, since you re-defined "i" and it didn't break the equations using the radical. I appended what you showed in the image to mine and it works the same as you depict, so I assume that is the only change.
Correct - I haven't changed anything you wrote and just appended what you see in the picture. It was easy to do because you already had all set up nicely in functions of fr. The range for fr you defined at the top of your sheet was just used for plotting. So you could have equally well defined it just prior to the plot.
Fortunately you could take all information from the picture. While its usual that a software can't read a file in a newer versions format its quite annoying that Prime is not able to save in the format of older versions like many other software shows how to do.
Thank you for this example showing what vectorization will do for me, that actually makes the change very easy.
Vectorization is a handy feature but also can be a pitfall if you forget about it and rely on Mathcads auto-vectorization feature.
here's a simple example: