Effacer les filtres
Effacer les filtres

I have a Problem.

1 vue (au cours des 30 derniers jours)
Matt Reiser
Matt Reiser le 4 Fév 2015
Commenté : Star Strider le 4 Fév 2015
x = linspace(-30,30,30001);
y = ((sin(x)) ./ (x));
plot(x,y,'-');
axis([-30 30 -.25 1])
xlabel('x')
ylabel('y')
title('Reiser Graph of sin(x) / x')
x = linspace(-20,20,20001);
y = (2 ./ ('sqrt(3+x.^2)'));
z = (-1 ./ ('sqrt(2+x.^2)'));
plot(x,y,z,'-');
Error using plot
Vectors must be the same lengths.
I am getting an error message on my second plot. Please Help

Réponses (1)

Star Strider
Star Strider le 4 Fév 2015
The second plot works if you:
  1. Lose the single quotes, and
  2. Use the plot3 function:
x = linspace(-20,20,20001);
y = (2 ./ (sqrt(3+x.^2)));
z = (-1 ./ (sqrt(2+x.^2)));
plot3(x,y,z,'-');
grid on
  2 commentaires
Matt Reiser
Matt Reiser le 4 Fév 2015
Modifié(e) : Matt Reiser le 4 Fév 2015
Need y and z on the same graph in 2D. can you help me with that?
Star Strider
Star Strider le 4 Fév 2015
Quite definitely!
You need to plot both the independent and dependent variables together as pairs:
plot(x,y, '-', x,z,'-')
grid

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line 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!

Translated by