- select points you need
- use trapz or polyarea
How to find the area if the traced are in the graph graph?
1 回表示 (過去 30 日間)
古いコメントを表示
Good day, I am trying to calculate the area of the traced area shown in the graph. This is my Matlab code.
y = [40 40 30 20 15 15 22 33 46 56 48 26 20 20];
x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14];
plot(x,y,'*')
ylim([0 60])
annotation('line',[0.7383 0.7969],[0.7576 0.4664])
annotation('line',[0.6759 0.7355],[0.873 0.7621])
annotation('line',[0.6294 0.6841],[0.7335 0.871])
annotation('line',[0.5742 0.6305],[0.5607 0.7379])
annotation('line',[0.5205 0.5747],[0.4112 0.5672])
annotation('line',[0.4078 0.5184],[0.3184 0.4126])
annotation('line',[0.8529 0.9074],[0.3829 0.3829])
annotation('line',[0.7953 0.8516],[0.4641 0.382])
annotation('line',[0.4028 0.9047],[0.3178 0.3769])
And is there a way to color the traced area like this one
Thank you so much.
0 件のコメント
採用された回答
darova
2020 年 7 月 8 日
y = [40 40 30 20 15 15 22 33 46 56 48 26 20 20];
x = [1 2 3 4 5 6 7 8 9 10 11 12 13 14];
ii = [5 7:length(x) 5];
plot(x,y,'*')
line(x(ii),y(ii))
trapz(x(ii),y(ii))
polyarea(x(ii),y(ii))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!