×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MathCAD Decision Statement

MathCAD Decision Statement

MathCAD Decision Statement

(OP)
I have the following statements in a MathCAD 14 program:

X=1
Y=2000
XPRIME <== (X + 13) if X < 3
YPRIME <== (Y - 1) if X < 3

I find that the "if" statements are not executing, running the following debug lines generates "variable undefined" error, returned in red text.

Adding the two lines:

X=
Y=

does return 1 and 2000 respectively, so I know that the variables are good prior to the "if" statements.

XPRIME =
YPRIME =

What is wrong with the syntax?  What am I missing?  

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD Decision Statement

(OP)
Yeah, there is some issue with the syntax.  I'm careful enough not to manually type the word "if", errors of that nature, picking it off the Program Pallette.  But I am fairly new to MathCAD and want to convert several older programs to such a format.

Here is the program.  I am correctly reading in the variables, but the decision block is not executing.  Don't know why, struggling with the logic somewhat.

Much thanks.  Program is attached.

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD Decision Statement

OK, better, but the actual sheet in M11 format would be more useful, so respondents don't have to re-type your equations.

Is this supposed to be a subprogram within Mathcad?  You're using programming constructs in step 3, but using regular sheet constructs everywhere else.  By program, I refer specifically to a worksheet component typified by a broad vertical bar with an assignment operator on the left, and a sequence of instructions on the right side.

It looks like you're trying to replicate the calculation from Zombeck's Astronomical Formulas, but in programmed function form?

TTFN

FAQ731-376: Eng-Tips.com Forum Policies
Chinese prisoner wins Nobel Peace Prize

RE: MathCAD Decision Statement

(OP)
I'm fairly new to MathCAD, only been using it for simple engineering computations.  I have several FORTRAN, C++ and Visual Basic programs concerning astrometric computation, some of them dating back twenty years or so, and was converting the Julian Date one as a simple exercise.

The MathCAD syntax is something mysterious, I have been using website examples and some of the Help Tutorials to get a better understanding, but this one has proven to be more problematic.  There is not a lot of reference material out there, "MathCAD for Dummies", that sort of thing.

The source algorithm for this one was Duffet-Smith.  The program is not fully debugged yet, I need to add the October 1583 delimiter, but was working with the January/February correction at the time this "if statement" problem arose.  Seems simple enough, just not executing properly.

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD Decision Statement

(OP)
Thanks Occupant.  Let me give that one a whirl!

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD Decision Statement

RE: MathCAD Decision Statement

I didn't like what I posted previously, I discovered some errors in there. So I did it again, the solution is analogous to yours, but I didn't quite like it because of the "MM+13", I think it should be "MM+12". As you can see on the attached, the in line "if" can be used as well as the programmatic one (the one with the bars)

RE: MathCAD Decision Statement

(OP)
Thanks again Occupant.  I still don't understand why that conditional "if" statement failed to execute in the original MathCAD program.  Any insight to this?

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD Decision Statement

The operator <- is for local definitions within a program.  This allows you to create variables that a program uses for intermediate steps that aren't needed outside the program.  These variables don't exist outside of the program so can't be called by an external function.  To store something that can be used later in the worksheet use :=.

Peter
 

RE: MathCAD Decision Statement

(OP)
Thanks PStuckey, I figured some sort of "global" verses "local" variable thing after reading such localization inside nested loops.  Kind of strange to me, but then again, I'm a newbie to MathCAD and am trying to get more out of it than simple formulation with calculation.

Anyway, thanks to this threads respondants, using all the inputs, I got the program intended, which is attached below.  Not perfect yet, but will work on AD years prior to 1582 Oct 15 and cases involving BC.

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

RE: MathCAD Decision Statement

(OP)
Here is the program, probably needs to be cleaned up a bit.

It runs correctly for years after 1582 October 15, and correct again for years -1 AD to 1582 October 15.  For some odd reason I am exactly one day out for the BC years.

Thanks again.

Kenneth J Hueston, PEng
Principal
Sturni-Hueston Engineering Inc
Edmonton, Alberta Canada

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close