Skip to main content
1-Visitor
September 4, 2014
Question

Having trouble looping through this program

  • September 4, 2014
  • 21 replies
  • 7073 views

Hi,

I am having trouble looping through this program. I am basically taking the FORTRAN approach (attached) and trying to implement it into MathCAD 14. I am confused on how to make some of the change over.

Any help would be greatly appreciated.

21 replies

23-Emerald I
September 4, 2014

Addison Mauldin wrote:

Hi,

I am having trouble looping through this program. I am basically taking the FORTRAN approach (attached) and trying to implement it into MathCAD 14. I am confused on how to make some of the change over.

Any help would be greatly appreciated.

Why, Oh why, would you want to drive Mathcad to be like FORTRAN?

I started into your sheet, and immediately ran into some unit balance problems.

There are far better ways to use Mathcad to solve this problem; the first is to use units and built-in physical constants to shorten your path.

Please! Forget FORTRAN. Put your PDF paper notes into Mathcad. Then try again.

msu121811-VisitorAuthor
1-Visitor
September 4, 2014

Thank you very much Fred. Please forgive my ignorance. I don't have a programing background at all.

I am at the point now where I have the sheet implemented, all with units. I am getting stuck on how to pull roots with units attached.

Also, assuming once I get the roots, how do I proceed forward in Mathcad to handle the steps 7. and 8. in my .pdf file?

Werner_E
25-Diamond I
September 4, 2014

Addison Mauldin wrote:

Thank you very much Fred. Please forgive my ignorance. I don't have a programing background at all.

I am at the point now where I have the sheet implemented, all with units. I am getting stuck on how to pull roots with units attached.

Also, assuming once I get the roots, how do I proceed forward in Mathcad to handle the steps 7. and 8. in my .pdf file?

You wrote "polyroot times vector" and did not call "polyroot of vector".

But even if you would have done it the correct way it would have failed, because Mathcad can't handle vectors consisting of elements of different dimensions (as a .. e are).

So you have either get rid of the units in the coefficients alltogether or at least bring all to the same dimension. The result will be unitless and you have to add the correct unit (s is obviously 1/time so I suggested Hz or 1/sec) manually:

1.png

P.S.: The powers of s are powers of the unit seconds and have nothing to do with the variable s.

msu121811-VisitorAuthor
1-Visitor
September 9, 2014

Just out of curiousity and my ignorance (see original post), what is the deal with Mathcad not having a GOTO function in its programming toolbar? I have read somewhere that was frowned upon by traditional programers but never understood why. How do you get around this in your own Mathcad programs?

23-Emerald I
September 9, 2014

I was told once (circa 1983) that a "good" programmer would never need an unconditional "GOTO" statement, that all things could be handled by cases, when, and if then.

That's about the time I stopped programming (in FORTRAN and BASIC.) I'm not sure, but I don't think "C" and its variants have an un directed transfer statement. I have done a bit of LabView (a GUI front end for essentially C) and there isn't one there. So Mathcad is not alone.

I tried to clean up and annotate yesterday's sheet.

msu121811-VisitorAuthor
1-Visitor
September 10, 2014

So thanks goes out to Fred again for helping me along. I think I am on the tip of putting this one to bed, finally .

Question: How do you get the Mathcad program loop to return every value for K_theta and Real for each iteration on K_alpha? In other words, I would like to see, for each value of K_alpha, a vector of K_theta and a vector of Real (yes I know this is a tremendous amount of data and yea I would make my steps alot bigger for i regarding K_alpha, say on the order of only 10 steps total). To simplify that amount of data, for each value of K_alpha, I would only like to see the associated values of K_theta only when Real =1. Not too much to ask for right, ?

Werner_E
25-Diamond I
September 10, 2014

Addison Mauldin wrote:

So thanks goes out to Fred again for helping me along. I think I am on the tip of putting this one to bed, finally .

Question: How do you get the Mathcad program loop to return every value for K_theta and Real for each iteration on K_alpha? In other words, I would like to see, for each value of K_alpha, a vector of K_theta and a vector of Real (yes I know this is a tremendous amount of data and yea I would make my steps alot bigger for i regarding K_alpha, say on the order of only 10 steps total). To simplify that amount of data, for each value of K_alpha, I would only like to see the associated values of K_theta only when Real =1. Not too much to ask for right, ?

Maybe like this.

msu121811-VisitorAuthor
1-Visitor
September 12, 2014

So there is probably a more compact way to do this, but I finally got the result I was looking to get. Thanks again for all the help especially to Fred and Werner.