Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi all,
I am new Mathcad user and stuck in using matrix in an equation.
I have equation X equal to other variables, one of them is Z which is varying in intervals. I put Z in a matrix, as showing the pic. I want X outputs in values or matrix, but mathcad show an error.
Is there a way that can form it to get X values based of z values rather than using many separate equations?
Solved! Go to Solution.
Careful... your formulation makes it look like you're squaring the matrix Z rather than its elements.
Define your solution variable as a vector. Then re-write your formula to solve for each of your solution indexed elements as your formula involving one of the indexed elements of Z.
Careful... your formulation makes it look like you're squaring the matrix Z rather than its elements.
Define your solution variable as a vector. Then re-write your formula to solve for each of your solution indexed elements as your formula involving one of the indexed elements of Z.
@Strib wrote:
Careful... your formulation makes it look like you're squaring the matrix Z rather than its elements.
That would be no problem! Because squaring is no valid operation for a vector, Prime automatically applies implicit vectorization.
Actually as written and explained in my answer below, not using vectorization does not throw an error but produces a wrong scalar result.
Just to explain what @Strib suggested:
Note the vector/matrix index "i" at f and every occurrence of Z.
Sure a way to get the correct result, but definitely not my preferred method (see my answer below) 😉
Thank you for help and the time you spent for me.
Hi,
Use the element by element operator Ctrl+Shift+^ to calculate element by element
It is very easy to implement and really helpful.
Thank you for help and the time you spent for me.
I see two failures in your picture and I strongly suggest that for future questions you always should also attach your worksheet.
The first failure, as was already pointed out by Terry, is that you need to use the vectorization operator if you want a calculation with a vector done element by element.
The second one I see is that for some reason you have an implicit multiplication between "atan" and the following opening parenthesis "(". This failure is the one which throws the error message.
Actually not using vectorization would not show an error but gives you a wrong scalar result. Reason for this is that you would multiply twice a vector with another vector and of course Prime must use the vector scalar product here (unless otherwise told via the vectorization operator).
IMHO it would be a much better approach to setup all calculation as functions depending on the values you want to vary - in your case thats "Z".
Then you can use this function to either calculate the result for single values of Z
or you can call the very same function with a vector as argument (remember to use vectorization!)
And of course you could also use this function to plot f over Z if you like (as you can see the division by zero which we get for Z=0 is generously ignored when plotting):
Setting up functions is much more versatile then setting up the calculations with vector from the very start.
I really appreciate this explanation and explaining what mentioned above.
Thank you for time, and the work.