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
- :
- Re: Three if Statement Formula

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- 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
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

07-01-2015
10:28 AM

07-01-2015
10:28 AM

Hi All,

I'm a newbie with Mathcad and I'm self taught so I hope this is an easy on for you guys!!

I'm trying to get my head round why this formula doesn't work so any help would be great.

See the attached Mathcad 15 file.

I'm using if statements to pick the correct answer but I can't get it to completely work. At one point I thought I had it but then when you test it there's always one way it fails. grrrrrrrrrrr

Best Regards

Jonno

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

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

07-01-2015
01:18 PM

07-01-2015
01:18 PM

Andy has already stated the problem with your (and Alans) routine.

The expression

will always simplify to TRUE and so despite the returns also Alans approach would yield AllowYield everytime, disregarding the value of Yield.

Here is an alternative approach which I guess does what you had in mind.

You might consider turning the routine into a function to be more versatile.

7 REPLIES 7

Highlighted
##

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

07-01-2015
10:37 AM

07-01-2015
10:37 AM

Re: Three if Statement Formula

Use the return statement to force the program to exit. Without that, as you note, it will always drop through to he next line.

Highlighted
##

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

07-01-2015
11:09 AM

07-01-2015
11:09 AM

Re: Three if Statement Formula

alternate suggestion.

1. the Boolean operators take 2 logical inputs so where you write IF yield = 60 OR 75, Mathcad checks if yield =60 is true; or if 75 is true. any non zero number is true so therefore 75 = true

This needs to be written IF yield=60 OR yield =75

2 you need to consider the logic of the next statement : IF yield NOT= 60 OR yield NOT=75

one of the statements must be true so this will always be true.

it needs to change to: IF yield NOT= 60 AND yield NOT=75.

Hope this helps

Andy

Highlighted
##

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

07-01-2015
01:22 PM

07-01-2015
01:22 PM

Re: Three if Statement Formula

This needs to be written IF yield=60 OR yield =75

Oops! Good catch. I missed that

Highlighted
##

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

07-02-2015
04:46 AM

07-02-2015
04:46 AM

Re: Three if Statement Formula

Thanks for answering my question Richard!!!

Highlighted
##

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

07-02-2015
04:45 AM

07-02-2015
04:45 AM

Re: Three if Statement Formula

Thanks for your reply! This works so i would of given it a correct answer but it wont let me put two correct answers down

Highlighted

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

07-01-2015
01:18 PM

07-01-2015
01:18 PM

Andy has already stated the problem with your (and Alans) routine.

The expression

will always simplify to TRUE and so despite the returns also Alans approach would yield AllowYield everytime, disregarding the value of Yield.

Here is an alternative approach which I guess does what you had in mind.

You might consider turning the routine into a function to be more versatile.

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

07-02-2015
04:46 AM

07-02-2015
04:46 AM

Re: Three if Statement Formula

Thanks Leopold!!

This works great and you have shortened my formula!!!