Why is my graph coming out blank when i try and plot this code?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
x=[0.1:0.1:5];
y=(sin(x))/x;
figure(2)
grid on
plot(x,y)
0 commentaires
Réponses (2)
Brian Hart
le 23 Fév 2019
It's an error in your calcuation of y. Check the size and you'll see it's coming out as a scalar. Replace "/" with "./", since you want element-wise division.
0 commentaires
Star Strider
le 23 Fév 2019
Because you are calculating a single point.
If you use element-wise division here (using ./ rather than /), you get the plot you expect:
x=[0.1:0.1:5];
y=(sin(x))./x;
figure(2)
grid on
plot(x,y)
0 commentaires
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots 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!