how to solve multi variable simultaneous equations

Hi all,
Please help me wiht this, I am new to matlab.
I want to solve two equattions which has five variable, so I want to provide ranges for three variables and get all the solutions.
3 variable with ranges are x4, x5 and z4, and I want to find corresponding solution for z5 and G. (Actually I have a formula which I nedd to equate with the real and imaginary part of a complex number)
I have tried this way-
x4=pi/36:pi/9:pi/2;
x5=pi/6:pi/9:pi/2;
z4=60:20:80;
for a=1:length(z4)
for b=1:length(x4)
for c=1:length(x5)
ZL=61.5-1i*47.4;
YL=1/ZL; % to be equated with its conjugate
GL=real(YL);
BL=imag(YL);
syms z5 real
syms z55 real
assume( z5 > 0)
syms G real
assume( G>0)
y4=1./z4;y5=1./z5;
ya(a,b)= -1i.*y4(a).*cot(x4(b)) % Formula -I
yb(c)=vpa((y5).*(G + 1i.*y5.*tan(x5(c)))./(y5+ 1i.*G.*tan(x5(c)))) %Formula-2
yeq(a,b,c)=ya(b)+yb(c) %sum
yeqR=real(yeq)
yeqI=imag(yeq)
eqn=[yeqR==GL, yeqI==-BL]
var=[G z5]
s=solve(eqn, var)
G1=s.G
z55=s.z5
end
end
end

댓글 수: 3

KSSV
KSSV 2018년 11월 13일
Why don't you show us the equation which you are solving? I feel like...loops are not needed to get the problem done.
Hedayat
Hedayat 2018년 11월 13일
Thanks KSSV,
below is the eqns, I have 5 variables and two eqns, so I have to assume 3 variables. (Later I will see if solutions are feasable or not)
ya= - i*y4*cot(x4)
yb= (y5 * (G+ i *y5* tan(x5))) / (y5+ i G* tan(x5) )
yeq=ya+yb
yL=1/(61.5-i*47.4)
Solve(yeq=yL*)
KSSV
KSSV 2018년 11월 13일
What are the unknowns in the above? YOu can solve it with hand first..equate complex and real parts...and these two parts should be solved for unknowns.

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

답변 (1개)

Hedayat
Hedayat 2018년 11월 13일

0 개 추천

Thank you again KSSV,
I need values for G and y5, and I want to sweep y4,x4 and x5, as I mentioned in main post. it wil not always yield a desired solutions. For example, I need a value of y5 in the range of 20-120 and G>0. Plus,based on these results, I have to add other complicated equations that too have some constraints , and this is why I am avoiding hand calculations.

질문:

2018년 11월 13일

답변:

2018년 11월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by