フィルターのクリア

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

1 回表示 (過去 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 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by