w- value

13 次查看(过去 30 天)
palash de
palash de 2011-12-15
Please help me...., i have a problem related to mathematics .....,
0.9987λ^4 -0.0013*w*λ^3 -(1.44+0.0007*w^2)* λ² -1.4311*w*λ-0.8*w^2=0 Equation no(1).
the above equation is a fourth order poly nomial equation and a determinant matrix=0.
det[1 1 1 1; exp(i*lemda(1)) exp(i*lemda(2)) exp(i*lemda(3)) exp(i*lemda(4));-(lemda(1))^2 -(lemda(2))^2 -(lemda(3))^2 -(lemda(4))^2;-(lemda(1))^2*exp(i*lemda(1)) -(lemda(2))^2*exp(i*lemda(2)) -(lemda(3))^2*exp(i*lemda(3)) -(lemda(4))^2*exp(i*lemda(4));]=0. Equation no(2).
By combining equation (1) and (2) five unknown quantities of λ (1,2,3,4) and ‘w’ can be solved.
If we put the value of ‘w’ in the equation (1) we can able to get the four roots of lambda because the equation (1) is fourth order polynomial equation and if we put four values of lambda in determinant matrix then the result becomes zero.
Here the value of ‘w’ infinite number by which the determinant becomes zero but I want only first three values of ‘w’ where determinant gives zero as a result and these are the values of ‘w’ which I required. I have tried to solve this problem in matlab software using Mfile. program is running but the problem is the program is not getting stop and for this reason I am not able to get the vales of ‘w’ in work space.
and adding matlab coding which i tried...., please check my coding...,
syms w;
w=1;
A=[0.9987 -0.0013*w -(1.44+0.0007*w^2) -1.4311*w -0.8*w^2];
lemda=roots(A);
q=[1 1 1 1; exp(i*lemda(1)) exp(i*lemda(2)) exp(i*lemda(3)) exp(i*lemda(4));-(lemda(1))^2 -(lemda(2))^2 -(lemda(3))^2 -(lemda(4))^2;-(lemda(1))^2*exp(i*lemda(1)) -(lemda(2))^2*exp(i*lemda(2)) -(lemda(3))^2*exp(i*lemda(3)) -(lemda(4))^2*exp(i*lemda(4));]
D=det(q);
while D~=0;
w=w+0.01
A=[0.9987 -0.0013*w -(1.44+0.0007*w^2) -1.4311*w -0.8*w^2];
lemda=roots(A);
q=[1 1 1 1; exp(i*lemda(1)) exp(i*lemda(2)) exp(i*lemda(3)) exp(i*lemda(4));-(lemda(1))^2 -(lemda(2))^2 -(lemda(3))^2 -(lemda(4))^2;-(lemda(1))^2*exp(i*lemda(1)) -(lemda(2))^2*exp(i*lemda(2)) -(lemda(3))^2*exp(i*lemda(3)) -(lemda(4))^2*exp(i*lemda(4));]
D=det(q);
end
for j=1:1000;
i=1:1:3
w(i)=w;
if D=0;
break
end
i am waiting for your answers..thank you.
  1 个评论
Jan
Jan 2011-12-15
I will not check you code if you do not care for a proper format. Please read the "Markup help" link on this page.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2011-12-16
I've look on the last few characters only:
for j=1:1000;
i=1:1:3
w(i)=w;
if D=0;
break
end
  1. The FOR loop is not closed by an END.
  2. Setting "w(1:3)=w" will not work, especially not repeatedly.
  3. "if D=0" tries to assign 0 to the variable D, what is not allowed in an IF condition. Perhaps you want "if D==0".
  4. But the value of D is not affected by the loop, such that it would be smarter to catch this outside the loop.
  5. To be exact: The contents of the loop is not affected by the loop counter at all, then the loop should be omitted.
Seeing this and the missing interest in posting the question in a readable format discourages me to look in the program any further.
  1 个评论
Walter Roberson
Walter Roberson 2012-1-5
Setting w(1:3)=w will work, Jan. w starts as the scalar 1. When w is a scalar, w(1:3)=1 is valid and extends w to be ones(1,3). Then in loop iterations after that, w(1:3) = ones(1,3) is valid.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by