how do I fill between 3 lines?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2023-9-28
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.
采纳的回答
Matt J
2023-9-28
编辑:Matt J
2023-9-28
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!