how do I fill between 3 lines?
1 view (last 30 days)
Show older comments
b = 48
time = 0:1:40000;
mFast = 6/30
mSlow = 4.3/30
yFast = (mFast*time)+b
ySlow = (mSlow*time)+b
plot(time,yFast);
xlabel("Time(Minutes)")
ylabel("growth in numbers")
title("Tribble Growth Rate")
legend("Harvester")
hold on
plot(time,ySlow,"DisplayName","Triple Triticale ")
ycutoff=time * 0 +5000
plot(time,ycutoff)
%i need to fill between the 3 lines thats given and need some help%
1 Comment
Walter Roberson
on 28 Sep 2023
I would recommend first calculating the points of intersection between the lines and ycuttoff . Doing so would allow you to calculate the coordinates of the 3 vertices of the triangle, and then you can fill using the coordinates.
Accepted Answer
Matt J
on 28 Sep 2023
Edited: Matt J
on 28 Sep 2023
One way:
b = 48;
time = 0:1:40000;
mFast = 6/30 ;
mSlow = 4.3/30;
yFast = (mFast*time)+b;
ySlow = (mSlow*time)+b;
plot(time,yFast);
xlabel("Time(Minutes)")
ylabel("growth in numbers")
title("Tribble Growth Rate")
L=legend("Harvester");
hold on
plot(time,ySlow,"DisplayName","Triple Triticale ")
ycutoff=time * 0 +5000;
plot(time,ycutoff)
L.AutoUpdate='off';
V=[0 0
roots([mSlow,b-ycutoff(1)]) ycutoff(1)
roots([mFast,b-ycutoff(1)]) ycutoff(1)];
hold on
plot(polyshape(V),'FaceColor','g')
hold off
0 Comments
More Answers (0)
See Also
Categories
Find more on Vector Fields in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
