Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello,
I have been using mathcad for years as a basic user, but do not have much experience using it for matrix operations or programming.
I am trying to create a worksheet that will allow me to feed in data in to several 3x1 matrices and then compare values of the elements of each matrix and then create a new matrix of only the largest values.
However, the resulting output of what I have at the moment is a scaler. How do I instead get a vector result? Please note that I am using Mathcad 15 (and not Mathcad Prime).
Thanks!
Solved! Go to Solution.
You get a scalar result from your function because a function always returns the result of the last statement executed.
You can define this function (I use a capital M, to distinguish it from the built-in function max ) :
Then you can use it to compare two arrays/vectors, e.g.:
like this:
Note that the vectorise operator is used (the arrow over Max(A,B), you get it by selecting the function and pressing [CTRL _], that is Control-underscore ), if not you'll get an error message.
The vectors need to be the same size, but can be any length.
Success!
Luc
You get a scalar result from your function because a function always returns the result of the last statement executed.
You can define this function (I use a capital M, to distinguish it from the built-in function max ) :
Then you can use it to compare two arrays/vectors, e.g.:
like this:
Note that the vectorise operator is used (the arrow over Max(A,B), you get it by selecting the function and pressing [CTRL _], that is Control-underscore ), if not you'll get an error message.
The vectors need to be the same size, but can be any length.
Success!
Luc
Many thanks! My version of mathcad did not like that if statement syntax, but I did get it to work as needed.
I did not use an if-statement, but the if-function... And Mathcad 15 should be happy with that as well.
Luc