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!

programming guide

Status
Not open for further replies.

skjoex

Structural
Jul 17, 2007
82
Hi,

I am new in Mathcad and honesly speaking quite disappointed.
In the past I used an Ansys parametric design language for my calculations. Since I learned to work with DO-LOOPs (in Mathcad FOR operator), arrays, tables and with IF command, there was almost nothing which I was not able programmed. I used 5-dimension matrices to store results, I used 10 level of nested do-loops in one calculation...I tried to program the same in Mahtcad,but it seem to me to be too complicated compared to Ansys. Can someone recommend some web-site, book, or another resouces ? Or would be someone so kind to explain the basic ?

For the beginig lets consider only two-level for-construction - see the file. I would like to return the values of awb and afb only if final condition is met and with results fill matrix 1x2...Why this does not work ?

Any advice is appreciated.

Lubo
 
Replies continue below

Recommended for you

There are problems:

>> Mathcad is NOT a programming language, although it has programming facilities. It is also not Matlab. What you have presented does not require a programming loop, since you are using indexed variables, and the calculations are directly evaluated as a result of the indexing.

>> A programming loop does not display anything. You need to assign it to a function, and then display the function.

>> Indices should start at zero, whenever possible. It's not mandatory, but many functions can and will barf with a different origin for the index.

>> You appear to be actually intending to use a Given-Find solve block. I suggest you read up on that in the Help.

>> Your final expression requires the use of functions throughout. Mathcad evaluates indexed variables immediately, so everything that you've entered is already evaluated.

>> Because you come from a background of using these types of constructs to solve problems, your tendency is to use these constructs in Mathcad. This is unnecessary, and ultimately counterproductive. Mathcad's solve block will given you the correct answer to the best numerical precision and tolerance possible.

I've attached a modification to your original file. Note that a.w.b and a.f.b are now the guess values for the solve block.

TTFN

FAQ731-376
 
 http://files.engineering.com/getfile.aspx?folder=739916b1-72fa-45fd-bd10-077fdfee96d2&file=test2.xmcd
TTFN,

thank you for your explanation! It is a nice work! Your way to solve my problem is clear and easy. Thank you again.
But unfortunately it means I have to learn completely different approach compared to APDL...

Lubo

P.S.:

...I think that problem is in very poor help file of mathcad compared to huge amount of features: I tried to find a FIND command in index of help file, but found nothing. Then I tried to insert funcion and found FIND funcion,but with completely poor description, there was not mentioned anything that something like GIVEN have to be but above. Then I tried find GIVEN function via insert funcion, but found nothing. Finally I found GIVEN via content of help file...
 
You should start with the tutorials, particularly if you are that unfamiliar with the program. There is a very clear example of a Solve block in the tutorials, as well as in the Mathcad Solve Block help page, which includes a quicksheet with a complete example.

And yes, you ought to learn a new way. Would you expect to use Excel the same way as your program? No. You'd likewise use the Excel Solve functionality. If you didn't need to change your methodology, there wouldn't have been any need to use Mathcad at all; you might as well have used APDL.

TTFN

FAQ731-376
 
Probably not appropriate to address IRstuff as TTFN since TTFN stands for "That's That For Now" or something else to that affect.
 
Actually, it's "Ta-Ta for Now" which is the signature remark from Tigger

TTFN

FAQ731-376
 
{Thanks. Still not much of a greeting though. }

That sounds like Eeyore speaking. Anyway, Tiggers don't have time for longer greetings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor