Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi Mathcad'ers,
It's been quite a few years since I last worked with Mathcad, and I don't remember if/how Mathcad could solve a system of equations with intermediate variables.
The sheet that I have put together results in an error for undefined variables if I do not place guess values for the intermediate variable. Do I need to put a guess value for these?
If I do set a guess value, I get an error that "this value must be a function".
What's the best way of addressing this?
The details for the sheet are:
I would like to determine a,b,o,and q as a function of g and s (inputs).
l,t, and p are constants.
j,o1,o2,b1,b2 are intermediate variables.
Thanks for the help,
Raphael
I can't open your file, but you likely just need to turn your intermediate values into functions of the variables you are trying to solve for.
For example, if j:=a+b, then make it j(a,b):=a+b. Then, anytime you use j in an equation, replace it with j(a,b).
Thanks Mark,
I tried this approach but i haven't had much success.Most likely because each function is a function of another. Here's the original sheet.
And a screenshot of the updated sheet- the error now is the initial guess must consist of scalars and matrices.
Regards,
Raphael
Raphael,
Your second screenshot does not show the solve block (guess values, constraints, solver on left side). I assume this just got cut off of your screenshot.
Aside from that, I see a few problems with your setup:
Also, as long as you define j after t & d, there is no need to make j a function of those variables (since you are not solving for those variables). Your definition of j could simply be j(a):=... The same goes for your other similar variables. There is nothing mathematically wrong with the way you have done this, but it would help clean things up.
A few more observations:
Some of your equations still reference j as a variable. They need to be revised to reference j as a function.
Your definition of b1 and the inequality that starts with q= both have 180 as a constant. I'm not exactly sure what these equations are supposed to represent, but please note that Mathcad's trig functions have angles in radians. If 180 is intended to be degrees, you'll need to convert. Note that the easiest way to "convert" between degrees and radians is to multiply by the unit "deg".
I decided to replicate your calculations and was able to get a result. However, the solver is very picky about what guess values are acceptable, and the results vary considerably from one guess to another. Here is one solution:
The solver is much more stable when you multiply the 180's by "deg":
> The solver is much more stable when you multiply the 180's by "deg":
I don't think that it has to do with stability. You simply get wrong results if you don't.
Apart from the definition of g Raphael forgot that Mathcad uses radiants when calculating with angles.
We could also define g:=0.6 deg
Werner