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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Solving for multiple unknowns

CF_10130026
6-Contributor

Solving for multiple unknowns

I'm trying to solve multiple unknowns using solve blocks but they don't seem to work. Is there another way to do this?

5 REPLIES 5

The first three equations you use in the solve block all suffer from the same problem:

The left hand side is a scalar, a single value, but the right hand side is a 15 x 1 vector.

A scalar never will equal a vector and so no solution could be found.

 

What do you actually mean by your equations?

 

If you meant that the four equations should be fulfilled for every of the 15 values in the vectors, then you could use something like

Werner_E_0-1716288060904.png

Yes, the left hand side is a vector and the right hand side still a single scalar, but the zero in this case is also treated as the zero vector and so it would work.

It may be more "legal" to actually use a zero vector on the right hand side. You could do so by multiplying one of the input vectors by zero:

Werner_E_2-1716288542254.png

 

But now the problem is that you actually habe 46 equations and just 4 values you try to solve for. Chances are that there is no solution for this overdetermined system.

You  could use "minerr" instead of "find" to let Prime find the values which gives the least overall error:

Werner_E_3-1716288590044.png

 

Werner_E_4-1716288611926.png

Werner_E_5-1716288916039.png

 

 

 

Hi,

What you need is a parametric solve block that solves the problem for each row of the vector inputs.

 

Ahh! Sure!

Unfortunately, the obvious idea that the four variables we were looking for should not be scalars but 15-element vectors, too, did not occur to me.

But all that's needed is to make the guess values vectors - otherwise the original solve block equations can remain unchanged! I create the necessary guess vectors by multiplying one of the given vectors (C.R) with zero, creating a 15 element zero vector and then adding the desired guess (1) to make a vector consisting of all 1's.

Instead of Terry's approach which returns a nested vector (15x1 vector with 4x1 vectors as elements) my approach returns a 15x1 vector for each of the four variables.

Which approach is more useful depends on the type of further data processing required.

Werner_E_2-1716301355696.png

 

Werner_E_1-1716301258241.png

 

Prime 10 sheet attached

 

 

 

Of course the guess vectors consisting of all 1's can be created in many different ways.

Her an example:

Werner_E_3-1716302094362.png

Werner_E_4-1716302112943.png

 

Prime 9 (!) sheet attached

Hello @CF_10130026

 

It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Community Moderation Team.

Top Tags