Issues with entering into MATLAB
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nicholas Deosaran
le 17 Sep 2020
Réponse apportée : Star Strider
le 17 Sep 2020
hello all I am trying to enter this into MATLAB but cant seem to get it right
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/362314/image.png)
x = 0:0.1:10
y= (2*x^1.01)+ sin(3*pi/2 *x)-10*cos(x)-3
plot(x,y)
[x,y]=ginput(n) % find the first 2 zeros
Please let me know if I am right or i did it wrong.
Thank you
0 commentaires
Réponse acceptée
Star Strider
le 17 Sep 2020
This sems to be homework.
Vectorise the expoinentiation:
y= (2*x.^1.01)+ sin(3*pi/2 *x)-10*cos(x)-3;
↑ ← HERE
Then to find the approximate indices of the zero-crossings:
zxi = find(diff(sign(y)));
Then use those with interp1 to find much more precise estimates of the zero-crossing x-values.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!