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
- :
- Again else If statements

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

04-28-2013
06:07 PM

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

04-28-2013
06:07 PM

Again else If statements

Hi everyone, I don't know what's happening to me, but when I think I know how Mathcad works, I'm not able to do a simple thing.

Mi problem today it's that I'm trying to do an "else if" statement but again, for some reason I cannot figure out how to program it. I've searched through the forum but I don't know how to fill the part that is missing (see image)

Again, if someone could give me a hand with this (I'm going crazy) I would appreciate.

Thx in advance.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

05-01-2013
07:57 AM

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

05-01-2013
07:57 AM

I didn't spot it the first time:

In the part you highlighted you ask if the x-difference is smaller or equal 3.848*10^-5. Inside this if-branch you then ask if the same difference is greater than that same value, which can never be (otherwise we would not be in that branch).

So your main problem seems to be that you put the follow up if inside the first if while you should have put it underneath.

I tried to correct your program, but its unclear to me what you want K2 to be. You provide 4 different values for K2 but only three different regions for the x-difference: (0..3.8*10-^5] (3.8*10-^5..1.8*10^-4) [1.8*10^-4..+inf)

See attached a possible solution which considers at leaast the three intervals for Delta-x. You have to change it to allow for the fourth value.

BTW, you will have a hard time trying to find a number which fulfills your condition 😉

11 REPLIES 11

04-28-2013
06:21 PM

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

04-28-2013
06:21 PM

There is no "else if" in Mathcad 15 and below.

From the help:

- If you use more than one
**if**statement before an**otherwise**statement, the otherwise statement is executed only when all previous conditions are false. However, all previous**if**statements continue to be evaluated regardless of the results of the previous**if**. In the example above fy(5) = 9 and fy(2) = 1. There is no "else if" or "case" statement in Mathcad that allows you to switch on multiple cases, other than to use nested**if ... otherwise**pairs.

Maybe the attched helps

05-01-2013
07:17 AM

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

05-01-2013
07:17 AM

Actually I've tried as you said, but as you can see in the image below it's not doing the comparison

05-01-2013
07:57 AM

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

05-01-2013
07:57 AM

I didn't spot it the first time:

In the part you highlighted you ask if the x-difference is smaller or equal 3.848*10^-5. Inside this if-branch you then ask if the same difference is greater than that same value, which can never be (otherwise we would not be in that branch).

So your main problem seems to be that you put the follow up if inside the first if while you should have put it underneath.

I tried to correct your program, but its unclear to me what you want K2 to be. You provide 4 different values for K2 but only three different regions for the x-difference: (0..3.8*10-^5] (3.8*10-^5..1.8*10^-4) [1.8*10^-4..+inf)

See attached a possible solution which considers at leaast the three intervals for Delta-x. You have to change it to allow for the fourth value.

BTW, you will have a hard time trying to find a number which fulfills your condition 😉

04-28-2013
11:43 PM

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

04-28-2013
11:43 PM

Use please not operator but function if:

04-29-2013
06:57 AM

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

04-29-2013
06:57 AM

Valery Ochkov schrieb:

Use please not operator but function if:

Why? I see no reason for not using the programming structure.

04-29-2013
03:45 PM

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

04-29-2013
03:45 PM

Norman Friedman wrote:

Valery Ochkov schrieb:

Use please not operator but function if:

Why? I see no reason for not using the programming structure.

I guess thats a matter of personal preference.

05-01-2013
07:20 AM

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

05-01-2013
07:20 AM

I'm working with Matchad 15, how I can use this form of statement?

05-01-2013
07:35 AM

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

05-01-2013
07:35 AM

Maikel Nite wrote:

I'm working with Matchad 15, how I can use this form of statement?

Same way! Get if function from Insert/Functions and use Add Line from Programming menu for the second and third inputs:

Alan

05-01-2013
10:32 AM

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

05-01-2013
10:32 AM

If I want use my worksheet in Mathcad Prime and in Mathcad Express (or Espresso) I must use not the operator (the statement) if but the function if. Mathcad Express has no proramming tools.

See my old tip #40 from the book "Tips for Mathcad users"

http://twt.mpei.ac.ru/ochkov/Sovet_MC/039/Tips_39_48_Eng.htm

05-02-2013
04:47 AM

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

05-02-2013
04:47 AM

I didn't even know this existed. Nice.

Mike

05-02-2013
04:55 AM

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

05-02-2013
04:55 AM

This is one of the first times I have saw a use for the 'else' conditional statement. Actually seems an improvement.

Mike