- select points you need
- use trapz or polyarea
How to find the area if the traced are in the graph graph?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John Reige Bendijo
am 8 Jul. 2020
Kommentiert: John Reige Bendijo
am 9 Jul. 2020
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 Kommentare
Akzeptierte Antwort
darova
am 8 Jul. 2020
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))
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!