Hello all,
Can you please tell me how can I solve 4 equations with 2 unknowns in MATLAB?

댓글 수: 3

Sean de Wolski
Sean de Wolski 2011년 7월 7일
Are they symbolic or numeric?
Sean de Wolski
Sean de Wolski 2011년 7월 7일
How is this urgent? Is it going to cure Cancer, end world hunger/tyranny, get us out of work early on this gorgeous Thursday, anything?
Bahareh
Bahareh 2011년 7월 7일
It is symbolic.

댓글을 달려면 로그인하십시오.

 채택된 답변

Sean de Wolski
Sean de Wolski 2011년 7월 7일

0 개 추천

Edited: Walk before you run:
syms x y
results = solve('3*x+y=9','x-7*y=-3',x,y)
results.x
results.y
look at
doc solve
to learn more.

댓글 수: 5

Bahareh
Bahareh 2011년 7월 7일
Thanks, I'm gonna try it now.
Bahareh
Bahareh 2011년 7월 7일
Sorry to bother you, before I use the solve command I did the following:
syms T12 T11 T21 T22 R11 R12 R21 R22 H21_1 H21_2 H12_1 H12_2 lambda beta alpha
>> (T21.^2.* H21_1.^2+beta^(-1) ).* R11.^2+(T21.* T2_2.* H21_1.* H21_2 ) .*R11.* R12=(lambda*alpha).*((R21.^2.* H12_1.^2+lambda).* T11.^2+(R21.* R22 H12_1.* H12_2 ).* T11.* T12 );
??? (T21.^2.* H21_1.^2+beta^(-1) ).* R11.^2+(T21.* T2_2.* H21_1.* H21_2 ) .*R11.* R12=(lambda*alpha).*((R21.^2.* H12_1.^2+lambda).* T11.^2+(R21.* R22 H12_1.* H12_2 ).* T11.* T12 );
|
Error: The expression to the left of the equals sign is not a valid target for an assignment.
How can I deal with this error?
Sean de Wolski
Sean de Wolski 2011년 7월 7일
First off, you don't have a valid variable T2_2. Second, to see if they're equal use '==' as opposed to '=' - an equality test as opposed to an assignment. Third, asking if they're equal like that will surely fail because not all variables are on both sides.
Fourth, to solve you input the whole thing into the function solve and then tell it what variable to solve for.
Bahareh
Bahareh 2011년 7월 7일
Thanks.
Bahareh
Bahareh 2011년 7월 7일
can you please explain your last sentence more?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 7월 16일

0 개 추천

syms T12 T11 T21 T22 R11 R12 R21 R22 H21_1 H21_2 H12_1 H12_2 lambda beta alpha
solve((T21.^2.* H21_1.^2+beta^(-1) ).* R11.^2+(T21.* T2_2.* H21_1.* H21_2 ) .*R11.* R12 - (lambda*alpha).*((R21.^2.* H12_1.^2+lambda).* T11.^2+(R21.* R22 H12_1.* H12_2 ).* T11.* T12 ), lambda)
Notice that the A=B form you had has been replaced by A-B, which solve will interpret as indicating that (A-B)=0 is desired.
In the second line, replace the "lambda" at the end by the name of the variable you want to solve for. As you only have one equation, you can only effectively solve for a single variable.
SooShiant
SooShiant 2014년 2월 20일

0 개 추천

Combine 2 equation to gain 1 then use this way:
Here is a simple example which you can change the equation and range and solve yours. The equation is 12x+9y+7z-60=0 where x,y,z are integers varies 0 to 10:
x=[0:1:10];
y=[0:1:10];
z=[0:1:10];
[X,Y,Z]=ndgrid(x,y,z);
F=12.*X+9.*Y+7.*Z-60;
idx=find(F==0);
[X(idx(:)),Y(idx(:)),Z(idx(:))];
Equations of this type are known as Diophantine equations.

질문:

2011년 7월 7일

답변:

2014년 2월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by