cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Solving system of equations with conditional statement

nc-2
1-Newbie

Solving system of equations with conditional statement

Hi,

I am just now discovering all that Mathcad can do and I am having trouble with solving a system of equations that includes a conditional statement.  If I manually input the statements into the system of equations (at the end), it solves it correctly, but I would like the equations to change based on the selection of LL case.  Any help would be appreciated!

Mathcad Question.jpg

Thanks,

Nichole

11 REPLIES 11
MJG
18-Opal
18-Opal
(To:nc-2)

I think you need to change your LLcase conditional statements so that they are functions of your three loads.  For example:

LLcase.int.LL.and.IM(P.int.LL.truck, P.int.LL.tandem, P.int.LL.lane) := ...

If that doesn't work, please post your worksheet (you can attached files by clicking "use advanced editor").

nc-2
1-Newbie
(To:MJG)

Mark,

Thank you for the response.  I'm still unable to get it to work.  I'm not that I understand all of the functions in the evlatuation toolbar (and haven't been able to find good examples that show the differences) so maybe I am using the incorrect one.

Thanks,

Nichole

tietjee
14-Alexandrite
(To:nc-2)

The problem may be with the programs.  The last line of the program will always be return.  You need to change the if statements to:

return x if case = 1

return y if case =2

etc.

nc-2
1-Newbie
(To:tietjee)

Thanks, David.  I'm still missing something....

Werner_E
24-Ruby V
(To:nc-2)

Mark has correctly suggested that you should use functions and you did it half way right. What you were missing was that you have to use those function in the solve block, too. That means not just the function names but providing the variables you wish to solve for as arguments, too.

Using "return" in every line is not necessary as your cases don't overlap and I don't think that the gain in performance speed is significant. But if you consider it good programming style, you may add those returns again. You may consider adding an "otherwise" line at the end of the functions to provide a value in case  LL.case is not an integer in the range of 1 to 5 (0 for instance).

You have three variables you want to solve for, but only two equations. But looking at your cases you always (apart from case 1) have only two variables involved. So Mathcad solves for those two and the third will remain 0 kip.

For LL.case=1 the solve block returns an error as no solution can be found. Thats understandable, because if you look at your equations in that case, you demand Mathcad to find a solution for the "system" consisting of the two equations

which obviously has no solution as "truck" can't be 198.241 kip (solution from the first equation) AND 263.66 kip at the same time

You would need to set CTOL:=10^5 to get Mathcad think it found a "solution"

Regards, Werner

nc-2
1-Newbie
(To:Werner_E)

Thank you Werner!! This works!  I think I understand now.  Thanks again!!!

nc-2
1-Newbie
(To:Werner_E)

On another note....Mathcad crashed as I was trying to save it.  I tried to insert a page break and it was too close to an argument (I've done this by accident before and now I'm kicking myself).  I don't have autosave (just set it up after this happened).  The file that was saving now says 0KB.  Previously, I've been able to search for .tmp files and rename them to recover Mathcad files when it crashes but when I did it this time, I am getting an error that says "The requested file is not a valid Mathcad xml worksheet".  The tmp file is 58,000KB so I know there must be something there.  I guess I learned my lesson but if there are any suggestions, I would really appreciate it!

Thanks,

Nichole

RichardJ
19-Tanzanite
(To:nc-2)

There's a Mathcad worksheet from Stuart here that may help you: http://communities.ptc.com/servlet/JiveServlet/download/169412-30612/xmcd%20recovery%20v2(2)%20(1).mcd.zip

Instructions are in the worksheet.

nc-2
1-Newbie
(To:Werner_E)

Also, when I try to open the .tmp file with Mathcad, I am getting the following error:

error.jpg

RichardJ
19-Tanzanite
(To:nc-2)

Can you post the file?

nc-2
1-Newbie
(To:RichardJ)

Thank you for the Mathcad worksheet from Stuart.  I don't really understand what it is doing so I might just do everything over again (I learned my lesson...)  I don't think I can post the file but I appreciate your help!  Thank you!

Top Tags