2D Matlab Plot help please
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Azzi Abdelmalek
le 27 Juil 2012
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
Réponses (3)
Wayne King
le 26 Juil 2012
The x and y variables must have the same length. What relationship is there between xdata and Revs?
0 commentaires
Image Analyst
le 27 Juil 2012
Modifié(e) : Image Analyst
le 27 Juil 2012
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 commentaires
Azzi Abdelmalek
le 27 Juil 2012
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 commentaires
Voir également
Catégories
En savoir plus sur Annotations 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!