How to solve for 4 variables from 5 equations that I have derived.

조회 수: 9 (최근 30일)
Shaumik
Shaumik 2012년 10월 2일
Hi, I have a problem in MATLAB. I am doing research in Optics ... I have to find 4 values from 5 equations and having some trouble. Kindly help.
I have tried reg this as below: I would be grateful to have any suggestions. Thanks in advance
clear
T = 0.89; R = 0.11; lamda = 0.98; d = 1.65; pi = 3.14; phit = 0.6; phir = 0.31; %((-(a))*d) == (23.03)*k;
% sym a b n k; % a and b are "alpha" and "beta"
a = sym('a'); b = sym('b'); n = sym('n'); k = sym('k');
eq1 = T == '({(1-R)^2+4*R*(sin(phir))^2}*exp((-a)*d))/((1-R*exp((-a)*d))^2+4*R*exp((-a)*d)*(sin(b+phir))^2)';
eq2 = (phit) == '((2*(pi)*n*d)/lamda)-(atan((k(n^2+k^2-1))/((k^2+n^2)*(2+n)*n)))+(atan((R*exp((-a)*d))*(sin2(b+phir))/(1-R*exp((-a)*d)*cos2(b+phir))))';
eq3 = (phir) == 'atan(((-2)*k)/(1-((n)^2)-((k)^2)))';
eq4 = (b) == '((2*(pi)*n*d)/lamda)';
eq5 = (a) == '((4*(pi)*k)/lamda)';
%eq6 = (e) == '((-(a))*d) == (23.03)*k';
[a b n k] = solve(eq1,eq2,eq3,eq4,eq5,a,b,n,k);

답변 (4개)

Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 2일
편집: Azzi Abdelmalek 2012년 10월 2일
Corrected code
syms a b n k;
eq1 ='T==(((1-R)^2+4*R*(sin(phir))^2)*exp((-a)*d))/((1-R*exp((-a)*d))^2+4*R*exp((-a)*d)*(sin(b+phir))^2)';
eq2 = 'phit==((2*(pi)*n*d)/lamda)-(atan((k(n^2+k^2-1))/((k^2+n^2)*(2+n)*n)))+(atan((R*exp((-a)*d))*(sin2(b+phir))/(1-R*exp((-a)*d)*cos2(b+phir))))';
eq3 = 'phir==atan(((-2)*k)/(1-((n)^2)-((k)^2)))';
eq4 = 'b==((2*(pi)*n*d)/lamda)';
eq5 = 'a==((4*(pi)*k)/lamda)';
sol= solve(eq1,eq2,eq3,eq4,eq5,a,b,n,k)
but it seems that you system does'nt have solutions. Notice that you have more equations then unknown variables

Shaumik
Shaumik 2012년 10월 2일
Thanks a lot for your help Azzi.. I will work on this and get back.

Shaumik
Shaumik 2012년 10월 4일
hello
I just put in the value of 'a' in the equations (program given below the error message), but getting this error. Any suggestions would be very helpful. Thanks
________________________________________
??? Error using ==> solve>getEqns at 182 ' T==((1-R)^2)+((4)*(R)*(sin(phir)^2))*(exp((-((4*(pi)*k)/(lamda)))*(d)))/((1)-(R)*(exp(((4*(pi)*k)/(lamda))*(d)))^2)+((4)*(R)*(exp(((4*(pi)*k)/(lamda))*(d)))*(sin(b+phir)^2)) ' is not a valid expression or equation.
Error in ==> solve at 67 [eqns,vars] = getEqns(varargin{:});
Error in ==> RI at 19 sol = solve(eq1,eq2,eq3,eq4,b,n,k);
________________________________________________________
T = 0.89; R = 0.11; lamda = 0.98; d = 1.65; pi = 3.14; phit = 0.60; phir = 0.31;
syms b n k;
eq1 = 'phir==atan(((-2)*k)/(1-((n)^2)-((k)^2)))';
eq2 = 'T==((1-R)^2)+((4)*(R)*(sin(phir)^2))*(exp((-((4*(pi)*k)/(lamda)))*(d)))/((1)-(R)*(exp(((4*(pi)*k)/(lamda))*(d)))^2)+((4)*(R)*(exp(((4*(pi)*k)/(lamda))*(d)))*(sin(b+phir)^2))';
eq3 = 'phit==((2*(pi)*n*d)/(lamda))-(atan((k(n^2+k^2-1))/((k^2+n^2)*(2+n)*n)))+(atan((R*exp(((4*(pi)*k)/(lamda))*d))*(sin2(b+phir))/(1-R*exp(((4*(pi)*k)/(lamda))*d)*cos2(b+phir))))';
eq4 = 'b==(((2)*(pi)*(n)*(d))/(lamda))';
%eq5 = 'a==((4*(pi)*k)/(lamda))';
sol = solve(eq1,eq2,eq3,eq4,b,n,k);
  댓글 수: 4
Walter Roberson
Walter Roberson 2012년 10월 4일
편집: Walter Roberson 2012년 10월 4일
What are sin2() and cos2() ? If you want sin-squared you need sin(x)^2
Shaumik
Shaumik 2012년 10월 4일
yes, you are right. i may have made a mistake there.
I am correcting that and trying again.
thanks for the help.

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


Shaumik
Shaumik 2012년 10월 4일
sorry to bother again.. I changed the sin-square and cos-square, but still the same error is coming. Dont know where I am going wrong.
Anyway.. I am keeping on trying.. meanwhile if you think of anything else that might help, please let me know. Would really appreciate it.
Thanks Walter for all the help.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by