How do i find roots for a trignometric function? eg (0.1*x)+10*tan(0.1*x)
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nitesh Panchal
le 9 Oct 2015
Commenté : Star Strider
le 9 Oct 2015
The function roots does not work for this equation ?
0 commentaires
Réponse acceptée
Star Strider
le 9 Oct 2015
Use the fzero function to get real roots. Plot it first, since it likely has several, and the initial estimate of the roots will reveal different values:
eqn = @(x) (0.1*x)+10*tan(0.1*x);
rt = fzero(eqn, 10)
rt =
15.7080
4 commentaires
Star Strider
le 9 Oct 2015
You don’t plot it with a for loop, you use the plot to estimate the initial guesses for the parameter. If those initial guesses are for instance 0, 15, 30, ... (that seem appropriate here), you would write the loop as:
X0 = [0:15:15*4];
for k1 = 1:length(X0)
rt(k1) = fzero(eqn, X0(k1));
end
x = linspace(1, 100);
figure(1)
plot(x, eqn(x))
hold on
plot(rt, zeros(size(rt)), 'or')
hold off
grid
Here, I plotted the function afterwards to demonstrate that it detected and estimated the first five positive zeros. The ‘rt’ vector has their locations.
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!