Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
I am pretty new to mathcad so working on and learning. Is it possible to get the result from programming in matrix form. I am trying but getting error. Can someone please help
Sam
Solved! Go to Solution.
As Luc already wrote, you have to iterate through your vectors, either by using a range variable, a program with a for-loop or by using vectorization.
Vectorization is quite convenient, but Prime won't allow to vectorize a comparison like AA<10 directly. But you can define a function which compares its argument with a given value and then call that function vectorized with your vector as argument.
Using a function may be convenient if you need the same or a similar comparison of a vector with a value more than once in your sheet. If the value you compare with (10 in your example) changes, you may make it the second argument of your function.
Its a matter of personal taste if you prefer the programmed if-branch or the if-function.
I am pretty sure that its possible to achieve what you have in mind, but to help you it would be necessary to see what you are trying to do.
So if possible you should attach your worksheet so we can have a look at and maybe it also helps if you additionally state which result you are looking for.
If you are using the newest version of Prime, it may also help to attach a picture (if the worksheet is short) for people (like me) not able to open worksheets saved by the current version.
@SS_9781956 wrote:
I am pretty new to mathcad so working on and learning. Is it possible to get the result from programming in matrix form. I am trying but getting error. Can someone please help
Sam
If you've managed to create a matrix in a program, then either put the name of the matrix as the last line of your program or use the return operator at the point at which you have completed your desired calculation.
Look at the Mathcad Help for examples.
An example of return with the try/on_error operator:
As Werner says, if you need specific help, please post a worksheet showing your attempts so far. That way you will likely get more tailored advice (and don't worry about the 'quality' of your worksheet - we've all written worse!).
Cheers,
Stuart
Yes, it is possible. See e.g.:
But you should attach your worksheet
Success!
Luc
So you are using Prime 7.
The problem is not with returning a matrix, you are trying to compare a vector with a scalar, that's not possible. You can only compare apples with apples...
One way is iterate through the vector, comparing:
Note that you will NOT get numeric results of 00, since 00 numerically is just 0.
Another way is to compare arrays and use vectorisation, e.g.:
Success!
Luc
As Luc already wrote, you have to iterate through your vectors, either by using a range variable, a program with a for-loop or by using vectorization.
Vectorization is quite convenient, but Prime won't allow to vectorize a comparison like AA<10 directly. But you can define a function which compares its argument with a given value and then call that function vectorized with your vector as argument.
Using a function may be convenient if you need the same or a similar comparison of a vector with a value more than once in your sheet. If the value you compare with (10 in your example) changes, you may make it the second argument of your function.
Its a matter of personal taste if you prefer the programmed if-branch or the if-function.
"Its a matter of personal taste if you prefer the programmed if-branch or the if-function."
Well, not really. The "if-function" works in Prime Express where programming "is a premium feature," and doesn't.
Werner,
Is it possible to use the equation within the program? With the results obtained i tried to use the row operator but it still remain matrix within a matrix and that is the reason I cannot use in later programmes. Thank you for your help.
Sam
The function sure could be used in a program.
Unfortunately currently I am unable to read Prime 7 files.
In the answer above I was able to look at your file because Luc kindly provided a lP6 version of it.
You can try posting a picture of the program you wrote and I will try to find out why it returns a nested matrix.
The row and column operators return arrays (row-vectors and column vectors, respectively), even if that row or column has only a single element.
Use the index operator instead.
Stuart
It's half-past three in the morning, my brain has gone walkabout, I'm listening to Deep Purple, and I'm not wearing sunglasses.
I'm puzzled.
What I see with the function head in place of the index operator is what I'd expect to see using the index operator under vectorization. My mental model of vectorization suggests that it should be working something like:
or even iterating over the expression,
Yet that's not what I'm seeing.
What am I missing here wrt to vectorization and the index operator?
Stuart