Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Want the oppurtunity to discuss enhancements to PTC products? Join a working group!
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Nov 17, 2022
08:10 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
08:10 PM

Using equation with a matrix variable

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.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Nov 17, 2022
08:36 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
08:36 PM

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.

7 REPLIES 7

Nov 17, 2022
08:36 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
08:36 PM

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.

Nov 17, 2022
09:25 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
09:25 PM

@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) 😉

Nov 17, 2022
10:10 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
10:10 PM

Thank you for help and the time you spent for me.

Nov 17, 2022
08:45 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
08:45 PM

Hi,

Use the element by element operator Ctrl+Shift+^ to calculate element by element

Nov 17, 2022
10:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
10:13 PM

It is very easy to implement and really helpful.

Thank you for help and the time you spent for me.

Nov 17, 2022
09:13 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
09:13 PM

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.

Nov 17, 2022
10:12 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Nov 17, 2022
10:12 PM

I really appreciate this explanation and explaining what mentioned above.

Thank you for time, and the work.