Finding Eigenvalues from an equation
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Roger Stafford
am 20 Feb. 2014
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.
Antworten (1)
Star Strider
am 20 Feb. 2014
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 Kommentare
Star Strider
am 20 Feb. 2014
Bearbeitet: Star Strider
am 20 Feb. 2014
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.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!