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!