필터 지우기
필터 지우기

how can I fill between two plot lines from a matrix?

조회 수: 4 (최근 30일)
Elizabeth Lees
Elizabeth Lees 2019년 1월 6일
댓글: Star Strider 2019년 1월 8일
Have loaded in my data and wanting the area between the two lines to be filled in. Lines have different values, not just flipped values! Code is below, thanks in advance.
naturalised=load('naturalised.csv')
max=plot(naturalised(:,1),naturalised(:,3))
min=plot(naturalised(:,1),naturalised(:,4))

채택된 답변

Star Strider
Star Strider 2019년 1월 6일
You did not post your data, so we can only guess what ‘naturalised’ is, although we can correctly assume that you are plotting columns of ‘naturalised’.
Try this:
figure
max=plot(naturalised(:,1),naturalised(:,3));
hold on
min=plot(naturalised(:,1),naturalised(:,4));
patch([max.XData, fliplr(min.XData)], [max.YData, fliplr(min.YData)], 'm')
hold off
grid
This worked with test data:
naturalised = [(0:20); zeros(1,21); 1+rand(1, 21); 3+rand(1,21)]';
It will probably work with your data as well.
  댓글 수: 2
Elizabeth Lees
Elizabeth Lees 2019년 1월 8일
thank you, worked perfectly!
Star Strider
Star Strider 2019년 1월 8일
As always, my pleasure!

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by