Skip to main content
12-Amethyst
April 3, 2024
Solved

Trouble assigning variable to solver output

  • April 3, 2024
  • 2 replies
  • 2178 views

I'm not able to assign the output of the solver to a variable.  I can do it with other examples, but it doesn't work with this expression.  What am I doing wrong?

 

FieldEng_0-1712155143218.png

 

Best answer by FieldEng

This worked well, which I had seen in the examples, but I hadn't fully digested how to use the solver for my case.  Your suggestion made me take a second look at this and a friend help me figure out how to implement this.  I can index the element of "sol" that I need and assign that to the variable I want to use.  Thanks for the help.

 

FieldEng_0-1712158724547.png

2 replies

23-Emerald IV
April 3, 2024

This is because the solution contains two ' variables'  that are unknown to the numeric processor: lbm and s.

You should tick the setting to allow units/constants in symbolics (under Calculation => calculation options), and see if that helps.

 

Success!
Luc

 

P.S. But the better way is to define mt as a function of its components and solve that:

LucMeekes_0-1712156738929.png

And then you can calculate its numerical value with:

LucMeekes_1-1712156784932.png

And do the same for the other two m-values.

 

 

FieldEng12-AmethystAuthor
12-Amethyst
April 3, 2024

Luc, unfortunately, this didn't work, but thanks for the tip.  I appreciate the quick reply.

-Kristan

25-Diamond I
April 3, 2024

I guess that setting the calc option to use units in symbolic calculations as explained by Luc will help (it not always does, though).

You may also consider to use the numeric (unit-aware) "root" function instead of the symbolic "solve" command. The "root" function can be used in two ways, either by providing a guess value or by providing an interval.

 

FieldEng12-AmethystAuthorAnswer
12-Amethyst
April 3, 2024

This worked well, which I had seen in the examples, but I hadn't fully digested how to use the solver for my case.  Your suggestion made me take a second look at this and a friend help me figure out how to implement this.  I can index the element of "sol" that I need and assign that to the variable I want to use.  Thanks for the help.

 

FieldEng_0-1712158724547.png

25-Diamond I
April 3, 2024

That doesn't look OK to me as you have just one equation but you solve for two variables!?