plotting 2 variable of different size length

6 ビュー (過去 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 Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by