Skip to main content
1-Visitor
June 6, 2013
Solved

Possible to create iterative solve blocks?

  • June 6, 2013
  • 11 replies
  • 5208 views

In the attached MathCAD 14 worksheet I am attempting to solve for the embedment length for multiple sets of variables ( concrete dimensions a,b,ma,mb) using the Given command/block. Is it possible to pass multiple groups of variables in these three equations and solve for the single variable E using the Given block?

For each set of variables only one equation is solvable for E while the other two will not be solveable. The solvable equation changes as the dimensions changes. If the equation is not solvable, is it possible to for MathCAD to return a zero or unsolveable response instead of turning red?

Best answer by Werner_E

Not sure what kind of iteration you are talking about in the subject.

But if you get riod of the range variable and the elementwise (subscribted/indexed) notation using it, make E a 3x1 vector and, again, use vectorize, you get a solution.

Not sure about what you mean with only one equ would give a solution?

Concerning error catching you could turn the solve block into a parameterized function (whatever the input parameters would be) and create a new function using the "on error" statement to return NaN if the solve block function fails. See attached

But in your case it failed always because of kind bad syntax.

11 replies

Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
June 7, 2013

Not sure what kind of iteration you are talking about in the subject.

But if you get riod of the range variable and the elementwise (subscribted/indexed) notation using it, make E a 3x1 vector and, again, use vectorize, you get a solution.

Not sure about what you mean with only one equ would give a solution?

Concerning error catching you could turn the solve block into a parameterized function (whatever the input parameters would be) and create a new function using the "on error" statement to return NaN if the solve block function fails. See attached

But in your case it failed always because of kind bad syntax.

12-Amethyst
June 7, 2013

If you make the solve blocks as parameterized functions you can calculate the 3 results.

if some of them don't converge to a solution there was a function "ReDefine" posted on this forum which takes a text string parameter.

if there is a variable of that name it returns the value, if not it returns "Undefined" & this can be used in subsequent calculations.

Hope this is what you want

regards

Andy

dsochor1-VisitorAuthor
1-Visitor
June 7, 2013

Thank you Werner; the vectorize function and the error check function are very useful. This worksheet will ultimately be used for the anchorage for a large number of columns, some of which will make allow the different Ac equations to be solvable for E and some will not be solvable for E based on the input parameters.

Is it possible for the solution of the f(E) function to show the solution E value for instances when the equation is solvable and NaN for instances when it is not? For example, in the attached worksheet, all three areas, 130, 140, and 150 in^2, will create a solution for the exterior column equation but only 140 and 150 in^2 will create a solution for the interior column. Is it possible for the g(gs) function to provide a 3 position vector with NaN in the first position and the solution E values in the second and third position instead of just providing a NaN for the entire solution?

Andy, I’ve never seen this redefine function before, thank you very much. I’m going to figure out how this page works, it looks like it may provide the functionality I’m after.

EDIT: The e1, e2, e3 functions work well when the parameters solve all three equations, thanks! What exactly should go into the ReDefine function to make the esub1, esub2, & esub3 work when the parameters don't solve the Ac equations?

19-Tanzanite
June 7, 2013

Daniel Sochor wrote:

Is it possible for the solution of the f(E) function to show the solution E value for instances when the equation is solvable and NaN for instances when it is not? ...

Like so?

Iterate.PNG

Alan