Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

using "solve" and getting rid of arbitrary parameters

$
0
0


I am trying to solve a system of equations whose answer will depend on arbitrary values.

For example, consider the following system of 2 equations and 3 unknowns:

syms x1 x2 x3
E=[x1+2*x2+x3;x3-x1+x2];
a=solve(E==0,x1,x2,x3)
A=[a.x1 a.x2 a.x3]


this gives me an answer that depends on an arbitrary value z. (infinitely many solutions).

I would like MATLAB to directly give me an answer (with no arbitrary values). So for instance, I would like to get an answer where the x1 value is positive. Is there a way to do that?

I am using "solve" in a subroutine, and after that, I would like to test the answer to see if it is a non negative array. But whenever the code reaches the answer, it tells me there is an error (obviously) because of the unknown parameter.

Viewing all articles
Browse latest Browse all 2703

Trending Articles