Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple programing to recognize "negative solution"

Status
Not open for further replies.

mar2805

Structural
Dec 21, 2008
372
Hi folks!
Somethnig Im trying to do but simply cannot find the solution.
Few questions.

I have an quadriatic equation wich sometimes creates negative number under the root expression.
I would like Mathcad to write an expression when this happens.
I tried doing this with simple programing.
Basicly what I did is add to lines with two conditions:
1st) "NOT AVAILABLE" if .................... (this is where I get lost, how to tell him when you get negative number under the squareroot?)
2nd) "AVAILABLE" otherwise


Is it possible to hide the function (expression) for wich you are finding the solution.
Like in previous egsample X:= two mentioned programing lines
Wich would finaly give X = something
How to hide "X=" so that you only see the result?


When using programing lines is it possible to define two action for one conditions and one action for the second condition?
Egsample if I have equation x-3=0
II"AVAILABE" I
II I if x>0
II"X=5" I
I "Not available" othervise

So basicly if x gives soution >0 I would like Mathcad to report an "AVAILABE" comment and give the solution x=5

Any chance for something like this?
Thank you.
 
Replies continue below

Recommended for you

Hi!
Heres the same solution (thanx to you) in another way.
But I dont understand how can MATHCAD calculate z value thats "under 5" if I didnt define the last programing line as "x1"?
Its seems that it went thru the last condition "greater then 5" if root(........)>5" saw that its not valid and anyway calculated the value.
On the other hand if I put 3rd programing statement as "x1" as soon my root equation is not vaild it returns error.
IRstuff whats your opinion?
 
 http://files.engineering.com/getfile.aspx?folder=44e5ee25-76aa-441d-a862-8220928e8ff1&file=Problem2d.xmcd
It doesn't need to be on the last line, it just needs to have been assigned and not over-written, and it needs to still be running the program.

As in algebra, order of operations is important, with the additional wrinkle that you have the option of ending the program prematurely. So, you have to pay particular attention to what you've commanded in the logical flow of the program. This is what makes programs so difficult to debug and maintain, which is further compounded by the innate lack of debugging tools in Mathcad.






TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
@IRstuff
Thank you very much!
Egsamples you posted where realy helpfull in understanding the importance order when programing with MATHCAD

@rmix22
How did you use these scriptable components?
Insert-> Component-> ???
 
mar2805 said:
How did you use these scriptable components?
Basically yes. The specific here was copied from another sheet of mine and then the VB code edited to fit your needs.
 
@mar2805: Sorry, I missed your ???'s

It's: Insert/Control/Text Box
then RightClick - Add InputVariable
then RightClick - Edit script
and off we go using VBScript commands
At last to clean up I chose to Hide Arguments (again RIghtClick)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor