필터 지우기
필터 지우기

Finding Eigenvalues from an equation

조회 수: 6 (최근 30일)
Mike
Mike 2014년 2월 19일
편집: Star Strider 2014년 2월 20일
Hello,
Im looking to find eigenvalues from an equation. Cosh(wx)*cos(wx)+1=0. For this equation i am looking for four different values dealing with w=1,2,3,4. Having trouble getting these in matlab? Any ideas?
  댓글 수: 1
Roger Stafford
Roger Stafford 2014년 2월 20일
If you tell us what you mean by "eigenvalues from an equation", perhaps we can help. Normally, eigenvalues are associated with a set of linear equations, but your equations are not linear in x.

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

답변 (1개)

Star Strider
Star Strider 2014년 2월 20일
I’m not sure what you’re trying, but if you’re looking for four different values of x corresponding to the different values of w, this works:
for w = 1:4
eqn = @(x) cosh(w.*x) .* cos(w.*x) + 1;
xval(w) = fzero(eqn, 1);
end
This gives:
xval = 1.8751e+000 937.5520e-003 625.0347e-003 1.1735e+000
  댓글 수: 2
Mike
Mike 2014년 2월 20일
편집: Mike 2014년 2월 20일
I got it to work, but its only gives the correct value for the first computation. If i change fzero(eqn , 1) from 1 to 4, 7, and 10 then i get all the correct answers. And idea how i can get all those to compute at once?
Star Strider
Star Strider 2014년 2월 20일
편집: Star Strider 2014년 2월 20일
I’m not sure what you mean by ‘all the correct answers’. There are several roots for each value of w, and the roots fzero finds depend on the starting point. Which ones are the ‘correct’ roots?
This will work:
for w = 1:4
eqn = @(x) cosh(w.*x) .* cos(w.*x) + 1;
[xval, fval] = fzero(eqn, 1);
vmat(w,:) = [w xval fval];
end
with
vmat =
1.0000e+000 1.8751e+000 222.0446e-018
2.0000e+000 937.5520e-003 222.0446e-018
3.0000e+000 625.0347e-003 -666.1338e-018
4.0000e+000 1.1735e+000 -23.9808e-015
The code is correct, and produces the correct answers. The rv matrix the following code produces is identical to vmat. The only difference is that eqn2 takes w as a specific argument. (The fzero function takes only one-parameter functions, and uses whatever is in the workspace for the other values in the function, so I couldn’t use eqn2 with it.)
eqn2 = @(w,x) cosh(w.*x) .* cos(w.*x) + 1;
for k1 = 1:4
fnv = eqn2(vmat(k1,1), vmat(k1,2));
rv(k1,:) = [vmat(k1,1), vmat(k1,2), fnv];
end
I feel vindicated.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by