Get Help

Turn on suggestions

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

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- IF Statements and Matricies

Options

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

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

Showing results for

Highlighted

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

02-10-2014
12:17 PM

02-10-2014
12:17 PM

MathCAD Prime 3.0

ISSUE 1: I have a square matrix representing collected test data. The data near zero is due to measurement inaccuracy. Thus, I would like to run it through a "filter" to make it zero in a resultant matrix. In Excel, a simple =if(x>1,x,if(x<-1,x,0) is the way to evaluate a given value. I have tried putting IF statements in a resultant matrix to "filter" the values, but Prime 3.0 crashes every time. What is a work around or better way to do this?

ISSUE 2: Now after getting the above to work, I need a clever solution to comparing matricies. I would like to compare the resultant matrix from above to another same size square matrix relative to whether the value is zero, negative or positive. I am specfically looking for a sign change indicating a change in direction fo displacement between what is measured in a test and what is predicted in an FEA simulation. (For the curious: I am comparing the shape of a structure based on 3 points and their X, Y, Z positions.)

Thoughts?

Thanks ahead of time for any help you can provide.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

02-10-2014
12:50 PM

02-10-2014
12:50 PM

Instead of using IF statements for #1, you could create a "mask" with Booleans. In the attached example, I look for values where the absolute value is greater than one. I can multiply the original vector with the mask to return only values that are greater than one. You can use the same trick for #2. Use the SIGN function to compare the signs of 'x' and 'y' and see when the two are different.

3 REPLIES 3

Highlighted
Instead of using IF statements for #1, you could create a "mask" with Booleans. In the attached example, I look for values where the absolute value is greater than one. I can multiply the original vector with the mask to return only values that are greater than one. You can use the same trick for #2. Use the SIGN function to compare the signs of 'x' and 'y' and see when the two are different.

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

02-10-2014
12:50 PM

02-10-2014
12:50 PM

Highlighted
##

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

02-10-2014
12:59 PM

02-10-2014
12:59 PM

Re: IF Statements and Matricies

That did the trick, thank you much, sir!

David

Highlighted
##

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

02-10-2014
01:32 PM

02-10-2014
01:32 PM

Re: IF Statements and Matricies

You're better off posting a worksheet with sample data showing what you want to achieve.

Im not quite sure about your second issue. Which value are you observing (for being +, - or 0)?

You may simple calculate the difference

Looking for sign change you have to deal with 8 cases you have to define what the outcome should be.

+/+ and -/- obviously should yield a 0, as no sign change happened

likewise +/- and -/+ yield -1 resp. +1

but what about 0/+, 0/-, +/0, -/0 ?

E.g. 0/- is not necessarily an indicator of a sign change from plus to minus - that depends on the next value.

See if the attched file helps at least for the first issue.