2D Matlab Plot help please
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi all can someone please help me here for matlab plot, I am using the matlab code below but getting an error message.
plot(xdata,Revs)
size xdata is 5 by 1 and size of Revs is 1 by 3000
am getting an error message which says "Vectors must be the same lengths"
what am trying to do is to plot xdata on the y axis and the Revs on the x axis.
댓글 수: 1
Azzi Abdelmalek
2012년 7월 27일
that means that you want to plot Revs(xdata), if xdata is 5 by 1; Revs must be too. Unless there is something else you want to do
답변 (3개)
Wayne King
2012년 7월 26일
The x and y variables must have the same length. What relationship is there between xdata and Revs?
댓글 수: 0
Image Analyst
2012년 7월 27일
편집: Image Analyst
2012년 7월 27일
Just get rid of xdata if you want the x-axis to be the array index,
plot(Revs, 'bo-');
or if you need the values for the x-axis tick marks, then try this:
xValues = linspace(min(xdata), max(xdata), length(Revs));
plot(xValues, Revs, 'bo-');
Wait - scratch that. You need to reverse those since you want to "plot xdata on the y axis and the Revs on the x axis":
yValues = linspace(min(xdata), max(xdata), length(Revs));
plot(Revs, yValues, 'bo-'); % Revs is the x and yvalues (i.e. xdata) is the y
See if that will produce a plot that looks like how you want it to look.
댓글 수: 0
Azzi Abdelmalek
2012년 7월 27일
try this code
xdata=[1 5 9 13 17 21]';Revs=rand(1,3000); %for example
plot(Revs);
ax1=gca;pos=double(get(ax1,'position'));
set(ax1,'visible','off')
ax2=axes('position',pos,'Color' ,'none')
x1=min(xdata);x2=max(xdata);n=length(xdata)-1
set(ax2,'Ylim',[min(Revs) max(Revs)], 'Xlim',[x1 x2],'xtick',x1:(x2-x1)/n:x2)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!