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

답변 (1개)

Star Strider
Star Strider 2015년 2월 4일

0 개 추천

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

Matt Reiser
Matt Reiser 2015년 2월 4일
편집: Matt Reiser 2015년 2월 4일
Need y and z on the same graph in 2D. can you help me with that?
Star Strider
Star Strider 2015년 2월 4일
Quite definitely!
You need to plot both the independent and dependent variables together as pairs:
plot(x,y, '-', x,z,'-')
grid

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2015년 2월 4일

댓글:

2015년 2월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by