Solving Non-Linear Equations

조회 수: 4 (최근 30일)
Shaumik
Shaumik 2012년 10월 15일
I am stuck up with the following program. I want to solve for 3 variables b, n, k. Please help.
for b,n,k I am getting <1x1 sym> how to get the values? Any help would be highly apprecaited.. Thanks
clear
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))+arctan(((k)*((n)^2+(k)^2-(1)))/(((k)^2+(n)^2)*(2+n)*(n)))+arctan((((R)*exp((4)*(pi)*(k))/(lamda))*(sin(b+phir)^2))/((1)-((R)*exp((4)*(pi)*(k)))/(lamda))*(cos(b+phir)^2))';
eq4 = 'b=(((2)*(pi)*(n)*(d))/(lamda))';
sol1 = solve(eq1);
sol2 = solve(eq2);
sol3 = solve(eq3);
sol4 = solve(eq4);

답변 (3개)

Rizwana Junaid
Rizwana Junaid 2012년 10월 15일
you can solve ur system by calling ode45 function. for that you will have to save all equations in one file and call the solver function from the other main file.
  댓글 수: 1
Shaumik
Shaumik 2012년 10월 15일
Thanks Junaid. But my non-linear equations are not in the differential form. So will ode45 work?
I am new to MATLAB and got stuck for a long time with this. Please suggest

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


Walter Roberson
Walter Roberson 2012년 10월 15일
You need to remove all of your apostrophes. If you are using R2012a or later, change your = that are in the equations to == but if you are using an earlier version, convert your A=B forms to (B)-(A) or (A)-(B) with no = or == in the definition of the expression. For example,
eq4 = (b)-((((2)*(pi)*(n)*(d))/(lamda)));
The result of your solve() is going to be a structure array with one field for each variable name. Access the field to see the value, such as
sol4.k
  댓글 수: 2
Shaumik
Shaumik 2012년 10월 16일
편집: Shaumik 2012년 10월 16일
Thanks Walter. I am using R2012a, and changed accordingly.
But got the error.
??? Undefined function or method 'arctan' for input arguments of type 'sym'.
eq3=phit==((2)*(pi)*(n)*(d)/(lamda))+(arctan(((k)*((n)^2+(k)^2-(1)))/(((k)^2+(n)^2)*(2+n)*(n))))+(arctan((((R)*exp((4)*(pi)*(k))/(lamda))*(sin((((2)*(pi)*(n)*(d))/(lamda))+phir)^2))/((1)-((R)*exp((4)*(pi)*(k)))/(lamda))*(cos((((2)*(pi)*(n)*(d))/(lamda))+phir)^2)));
Shaumik
Shaumik 2012년 10월 16일
Thanks Walter.. I am still getting some other errors now :( I am confused about where I'm going wrong. Is my approach correct?

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


Sachin Ganjare
Sachin Ganjare 2012년 10월 16일
Undefined function or method 'arctan' for input arguments of type 'sym'.
Matlab function name is 'atan' and not 'arctan'
Hope it helps!!!
  댓글 수: 3
Sachin Ganjare
Sachin Ganjare 2012년 10월 16일
편집: Sachin Ganjare 2012년 10월 16일
Probably you do not need quotes in your equation.
Check in your version of matlab documentation.
Hope it helps!!!
Shaumik
Shaumik 2012년 10월 16일
Yes, I removed the quotes as well (version is R2012a). I replaced the = sign with == as well.

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

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by