フィルターのクリア

How to: Merging multiple graph lines

34 ビュー (過去 30 日間)
Patrick
Patrick 2014 年 10 月 18 日
編集済み: vi trung kien 2018 年 3 月 21 日
Hello Guys,
my problem is that I have several data sets of different x-Arrays and always the same y-Array. Basically my plot functions looks like this: plot(x1,y,'g',x2,y,'b'....)
As I have drawn in the picture I want to merge all the lines as to always keep the lowest y-values going from left to right in terms of x-values. This should creat one single new plot that looks like the black line in the right picture. The left picture demonstrates the overlapping data sets.
Can I solve this problem graphically, e.g. using a plotting function to always display the lowest y-value or do I need to create a new 2D array that always picks the lowest y-value for every x- value? Maybe you can give me a base to start from. Sorry about my "untechnical" explanation, Im new to Matlab and coding in general.
Thanks in advance for your support. Pat
  2 件のコメント
Guillaume
Guillaume 2014 年 10 月 18 日
It looks like you meant to attach or (better) embed a figure, but seems like you forgot
Patrick
Patrick 2014 年 10 月 20 日
Thanks Guillaume,
just attached the image.
Regards Pat

サインインしてコメントする。

採用された回答

Guillaume
Guillaume 2014 年 10 月 20 日
編集済み: Guillaume 2014 年 10 月 20 日
I would concatenate all your x, get the unique values and their position and use the position with accumarray to get the minimum of y:
xall = [x1 x2 x3 ...];
[x, ~, indices] = unique(xall);
y = accumarray(indices, repmat(y, 1, N)', [], @min); %where N is the number of xi
plot(x, y);
edited for missing comma
  10 件のコメント
Patrick
Patrick 2014 年 10 月 26 日
Thanks for your reply, I will see what the results might be, but I get your point with the noise. That's the reason I was looking for a graphical approach to my problem in the first place. Do you know of any other mehtod tol realize what I pointed out in the attached image?
Patrick
Patrick 2014 年 10 月 27 日
Okay, I put the resulting diagram into the attachment. For my purpose the occurring noise is not really significant. Thanks a lot for your help, Guillaume!

サインインしてコメントする。

その他の回答 (1 件)

Rick Rosson
Rick Rosson 2014 年 10 月 18 日
x = [ x1 x2 x3 ... ];
N = length(x)/length(y);
y = repmat(y,1,N);
plot(x,y);
  2 件のコメント
Patrick
Patrick 2014 年 10 月 20 日
Hello Rick,
thanks for your answer! It gives me the same results as my previous code though:
figure(1) plot(n1,bcr,'b',n2,bcr,'r',n3,bcr,'y',n4,bcr,'m',n5,bcr,'m',n6,bcr,'g',n7,bcr,'k',n8,bcr,'b',n9,bcr,'r',n10,bcr,'y')
VS:
figure(2) n = [n1 n2 n3 n4 n5 n6 n7 n8 n9 n10]; N = length(n)/length(bcr); bcr = repmat(bcr,1,N); plot(n,bcr)
However, I dont want 10 individual graph lines in one diagram. What I need is one single united line that always displays Ymin(n), like I have scatched in the pictures attached.
Oops, sorry about that attachment. Forgot to hit the "Attach file" button.
vi trung kien
vi trung kien 2018 年 3 月 21 日
編集済み: vi trung kien 2018 年 3 月 21 日
Dear Patrick, Can you suggest for me how to get one single united line that always displays Ymin(n), like you have scratched in the pictures attached.My problem the same as you before. Thanks for your help.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by