solve two equations for two unknown variables

조회 수: 23 (최근 30일)
yasser
yasser 2011년 12월 20일
how can i solve two equations for two unknown variables?
like these two:
z=f1(x)+f2(y)
z=f3(x)+f4(y)
for z=0
please help, thx in advance.

채택된 답변

Dr. Seis
Dr. Seis 2011년 12월 20일
G*m = d
G = [f1,f2;f3,f4];
d = [z1;z2];
m = G\d;
x = m(1);
y = m(2);

추가 답변 (5개)

Walter Roberson
Walter Roberson 2011년 12월 20일
That cannot be solved without knowing f1(x), f2(y), f3(x), f4(y)
Are f1, f2, f3, and f4 perhaps constants, as in f1*x + f2*y ? If so then the solution is x = 0, y = 0, unless f1*f4 = f2*f3

yasser
yasser 2011년 12월 20일
now how can i solv it?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 20일
If your equations are
0=f1*x+f2*y
0=f3*x+f4*y
then the only solution is x = 0 and y = 0, unless it happens that f1*f4 = f2*f3 is exactly zero.
If f1*x + f2*y = 0 then y = -f1/f2 * x . Substitute this in to f3*x + f4*y = 0, and you end up with -x*(f1*f4-f3*f2)/f2 = 0 . That has solutions only if x = 0 or f1*f4-f3*f2 = 0 . If you try x = 0 then because f1*x + f2*y = 0, then f1 * 0 + f2*y = 0, then f2 * y = 0, which has a solution only if y = 0 or f2 = 0. But if f2 = 0 then the solution for x would have had a division by 0 so that possibility is out. This leaves only x = 0 and y = 0, or f1*f4 = f2*f3

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


Brian
Brian 2011년 12월 20일
you can solve a 2x2 by substitution or you can use rref.m. substitution is probably easier in this case!

yasser
yasser 2011년 12월 20일
sorry, my bad in my case , i would say z1=ax+by z2=cx+dy a,b,c,d constants i want to put z1=const1 & z2=const2 then solve and find x & y ?
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 20일
x = (f4*z1-f2*z2)/(f1*f4-f3*f2)
y = (f1*z2-f3*z1)/(f1*f4-f3*f2)

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


yasser
yasser 2011년 12월 20일
@elige grant thx alot

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by