필터 지우기
필터 지우기

Error using ==> plot

조회 수: 2 (최근 30일)
John
John 2011년 6월 9일
I tried to complete the plot of a sin wave.
This is my code:
EDU>> t = 0:0.5:1; % sample points from 0 to 1 in steps of .5
EDU>> x = sin(2*pi*t); %Evaluate sin(2 pi t)
EDU>> plot(t,x,'b'); %Create plot with blue line
EDU>> xlabel('t in seconds'); ylabel('x(t)'); %Label axes
EDU>> title('Plot of sin(2\pi t)'); %Title plot
I received the error:
??? Error using ==> plot Vectors must be the same lengths.
Please help.

답변 (2개)

Andreas Goser
Andreas Goser 2011년 6월 9일
Your code runs successfully on my machine. What OS and MATLAB Release do you use?
Can you verify t and x have the same size right before the line that causes the error (likely plot) by
whos t x

Harsha Vardhan Rao  Avunoori
Harsha Vardhan Rao Avunoori 2011년 6월 9일
Yeah!!! Your code runs properly on my machine too. Since you have initialized t to take values between 0 and 1 in steps of 0.5 I see the graph was plotted for three points at t=0,0.5 and 1.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by