Finding Eigenvalues from an equation
1 次查看(过去 30 天)
显示 更早的评论
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
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
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 个评论
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!