plotting 2 variable of different size length

조회 수: 9 (최근 30일)
Kehinde Adeniji
Kehinde Adeniji 2014년 4월 2일
댓글: Joseph Cheng 2014년 4월 2일
Hi all, Am trying to plot 2 variable of different size length in matlab GUI using push button, but because the variables are of different length it will not work,is there a way i can make it to plot?
d= pdist([x,y,z],'euclidean') ; % value of my distance
dd= 1:10:d; % interval and end 'd' value
FSL=-120; %value of free space loss get from the GUI
DFSL= 1:10:FSL %interval and end at FSL value
plot(dd,DFSL)
The plot code did not work coming back with an error " Error using plot Vectors must be the same lengths"

답변 (2개)

Joseph Cheng
Joseph Cheng 2014년 4월 2일
You should look at the help documentation for plot(), How you have it written is you are plotting dd versus DFSL. I do not know what your x axis is or if DFSL and dd have the same x axis (ie. d(1) and DFSL(1) should be in the same x axis point.
from the plot() documentation you need to specify the x and y values for your plot.
example:
plot(1:length(dd),dd,1:length(DFSL),DFSL)
  댓글 수: 2
Kehinde Adeniji
Kehinde Adeniji 2014년 4월 2일
Thanks,do you know how to get the length of the variable please?
Joseph Cheng
Joseph Cheng 2014년 4월 2일
with length()

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


Star Strider
Star Strider 2014년 4월 2일
I suggest using the linspace function.
dd = linspace(1, d);
and
DFSL = linspace(1, FSL);
This generates 100-element vectors between 1 and d for dd, and between 1 and FSL for DFSL. (You can change the number of elements for both with the third argument to linspace.)
I also note that you defined FSL = -120. Be careful with that, since it could also cause problems with the plot since you defined DFSL to begin at 1.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by