cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Iteration end condition

ptc-2830100
1-Visitor

Iteration end condition

Hello there.

I have used Mathcad once or twice and now I have come against an
issue I can't solve by reading the help....
I am trying to put a logic end to an iteration. The trouble is that the
iteration is to be performed over a lengthy amount of equations. I
cannot see how I fit these into a programming function (just too
much information), that allows me to return the result of the
calculation if GZ=GZ1.
[As you can see GZ is dependent of phi and I need to iterate this
over various phi. At the moment I have a fixed value of phi.]

Help??
9 REPLIES 9

If you are going to want to evaluate an expression for different values of some parameter (here, apparently, φ) just make that expression (or those expressions, if more than one) explicit functions of the desired parameter(s). As far as iteration goes, you usually just use find (or root) to find the parameter value(s) that meet specified conditions.
__________________
� � � � Tom Gutman

Thanks for that! I gathered that from the help files, the thing I can't
get my head around is the amount of expressions I have that need
to go into the if condition ( I think they don't fit :-|). Do you have a
suggestion how I can do this? Should I try to make one long
equation out of it??? Sorry for being dim.

>Do you have a suggestion how I can do this ?<<br> _________________________

YES, "Save as 11" or lower, a large community will look at it.

jmG

DOn't make φ a vector. That's the wrong way to do it. As far as I can tell φ has a single value, the only problem is that you don't know what that value is. That is what functions do.

You don't need to make a single expression out of everything. You can define functions in terms of other functions. Just go through your equations. For every variable whose value depends on φ make it a function of φ.

Your comments also indicate Vs as a guess value. That suggests that its value, like φ's, is not actually known and that all variables that depend on Vs should be explicit functions of Vs. But note that with two unknowns (φ and Vs) you will need two constraints to be able to get a solution. Possibly you have Vs as a function of φ somewhere (I didn't look through the sheet in that much detail) in which case you can just use that definition. Possibly there will be some other condition, in which case you will have two constraints in the solve block.
__________________
� � � � Tom Gutman

Thanks Tom and JmG.

I have still not gone any further as I didn't see the "Don't make it a
vector" on Saturday. So, I spent my time vectoring 😞
Anyway, I will now look at the function/solve block thing.
Tom, you are right after the first phi hurdle, I have a second
condition for Vs, but I gathered I could already ask what the syntax
is as I reached the point of the first logic problem.

Two more simple question: Will I have to put all functions inside the
solve block? and Do solve block work 'nested', i.e. Phi condition
and Vs condition (and actually there will be a third one too) or do
they need to be sequential?
Right, I am gone now as while I am posting here I can't actually
play Mathcad.

Thanks to you again.
Kim

You don't put functions inside a solve block. The only things that should appear within a solve block are the constraints, the equations to be solved.

And these should be a minimal set. If you have a variable constrained to be a function of some other variables (not including itself) that variable should be defined as a function, outside the solve block. Any references to that variable within the solve block use that function.

When you have multiple unknowns you cannot generally do them individually. Usually they are interdepedent so that you need to do simultaneous equations, multiple constraints (and unkowns) in a single solve block.

Some other general tips.

Never write the same expression more than once. You just make the sheet longer, and introduce more opportunities for error. For example, you have the expression π/180 appearing many times. That is actually the vaue of the built in degree unit, either deg or ° (I prefer using °, for conciseness and general readability). In duplicating that expression you have on case with the unlikely parameter of 14180.

If you have a series of expressions that are the same except for an index use a loop. Don't rewrite the expression for each index value. When you want to do an interpolation for all rows of the coefficient matrices, loop through the rows.

When you have essentially the same calculation done with different data, don't rewrite the calculation. define a function and invoke that function with the different data values. You have the same interpolation done with different coefficient matrices, you should have a single function which takes the matrix as a parameter and does the interpolation.

It may help if you start with the simple cases in the tutorials and quicksheets, rather than the complicated case you eventually want to solve. Mathcad is a tool, and while it will make short work out of your problem, it will do so only once you have learned how to use it properly and effectively.
__________________
� � � � Tom Gutman

Make it dependent of phi in an assignment. If phi ranges nicely (equally incremented), Mathcad will nest all the solutions that you may or may not be able to explode. In this case and in the case phi is anything not rangeable, include in a program. [Help ?] for new Mathcaders is this collab. This kind of problem appear several times a month, all solved ... most if not all in version 11.

jmG

Thanks for the tip with 11. I had no idea! I will try that tomorrow, if
I don't get further with the 'assignment' suggestion. I guess that
means make phi a vector.
Sorry for being dim.

On 8/8/2009 3:48:59 PM, klimbimi wrote:
>Thanks for the tip with 11. I
>had no idea! I will try that
>tomorrow, if
>I don't get further with the
>'assignment' suggestion. I
>guess that
>means make phi a vector.
>Sorry for being dim.
_____________________________

Your answer is there:

http://collab.mathsoft.com/~Mathcad2000/read?126700,11e#126700

Up until now, all your visits hit the wall.
You may be wrongdoing from the very first step.
About "Solve blocks" there is no + expertise than in this collab.

jmG
Announcements

Top Tags