×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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!
  • Students Click Here

*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

Jobs

Programming in mathcad

Programming in mathcad

Programming in mathcad

(OP)
Hallo everyone.
I'm a newuser in M. and I'm trying to "convert" a simple
basic listing to mathcad.
Despite my efforts I still can't get any good result.
Following the prg. (heat transfer).
JJerman


10 alung = .02
20 are = .24 * alung
30 port = .01648
40 qint = 0
100 h = 60
110 t1 = 680
120 t2 = 80
140 FOR i = 1 TO 50
150 q = h * (t1 - t2)
160 qtot = are * q
170 cp = .64545 * (t1 - 500) + 687
180 dt = qtot / (port * cp)
190 t1 = t1 - dt
200 qint = qint + qtot
220 alung = alung + .02
230 NEXT i

 

RE: Programming in mathcad

See the attached file.  Result is a vector containing several of your program variables.  The last statement assigns the elements of Result to different variables.  If you are only interested in one variable, say alung, change the last program statement to alung and Result will equal its value.

RE: Programming in mathcad

It looks like a temperature simulation program simulating the temperature dropping from 680 to 80 degrees.  If so this can be simulated in a differential equation a lot more cleanly and accurately but that wasn't what was asked for so I wait.
 

RE: Programming in mathcad

jgrhist,
That was the clearest example of a MathCad program I've ever seen (all of the examples in the book have extra stuff that muddies the water for me).  I program in MathCad all the time and it always surprises me when a program works.  I can read every line of your program and understand what it is doing and why it is there.  Thank you.

David

RE: Programming in mathcad

Tom Gutman has responded to your posting in the Mathcad Collab.  If you are indeed trying to solve a differential equation, Mathcad has more direct solutions than grinding through a FOR loop.

As Tom suggests, you should look at the original problem in your book, and apply Mathcad directly to the solution, rather than trying to duplicate the results of the BASIC program.

TTFN

FAQ731-376: Eng-Tips.com Forum Policies

RE: Programming in mathcad

Thanks, David, but all I did was translate the OP's Basic language program to Mathcad.  The original program was clear so the translation was clear.  

There's no great trick to programming in Mathcad except to realize that there is only one result.  All of the other assignments within the program are local only and cannot be used outside the program.  Only the last statement is returned as the value.  The result can be a matrix, so you can get other values from it.

Most of the programs I use in Mathcad are short ones that probably could be done cleverly without programming, but not nearly as clearly.  I use the programs for clarity in documentation as much as anything else.
 

RE: Programming in mathcad

You can get something other than the last value returned by adding a line at the end and specifying which local variable you want returned.  That helps with debugging.

RE: Programming in mathcad

I understand, I write programs all the time.  The problem I have is knowing exactly what all the parts and pieces of the program do.  I always find myself guessing what a particular line of a cut-and-paste does, and usually guessing wrong.  The program you posted made sense to me and I understood the function of every line and every component.  I've never been able to say that before, even on programs that I "wrote" from scratch--there is always some part that I stuck in there because it worked in the past.  Clear examples are scarce.

David

RE: Programming in mathcad

Quote:

You can get something other than the last value returned by adding a line at the end and specifying which local variable you want returned.  That helps with debugging.
But then the last line is the last value returned.  Using the "return" statement instead of assigning a local variable as the last program statement has the same effect.  I do think using "return" is preferable because it clarifies what is happening.
 

RE: Programming in mathcad

Ok, to each his own...

RE: Programming in mathcad

What is the best way to learn the MathCad syntax of programming?

RE: Programming in mathcad

(OP)
1st thanks everybody!!
2nd the code should compute heat tranfer and temperature
variation in a steel sheet moving through a cooler (1m lenght) where it
is cooled by nitrogen at high speed.
h is the film coefficient evaluate in a condition of
forced convectione inside the cooler.
Of course it could be solved via differential equation
(but I'm not able to use them with mathcad).
thanks again
 

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!


Resources