
Fill out Plot between V_Out1 and V_Out3
4 views (last 30 days)
Show older comments
Hi,
I tried to fill out the Area between the 3 Plots described by the 3 functions (or rather only the upper and lower one) but it didn't work out as I wanted it to be. First I don't think I did the Interval correct because there is no break between -5 and 5kW and also I don't really know how to use the fill function (I just took it from a video from youtube).

2 Comments
Answers (2)
darova
on 17 May 2020
flip the data
xx1 = [t1 flip(t1)];
yy1 = [V_Out1 flip(V_Out3)];
xx2 = [t2 flip(t2)];
yy2 = [V_Out4 flip(V_Out6)];
patch(xx1,yy1,'r')
patch(xx2,yy2,'r')

1 Comment
darova
on 17 May 2020
Or use surf in this case
h1 = surf([t1;t1],[V_Out1;V_Out3],[t1;t1]*0);
h2 = surf([t2;t2],[V_Out4;V_Out6],[t2;t2]*0);
set([h1 h2],'facecolor','r','edgecolor','none')

Star Strider
on 17 May 2020
Add these patch calls:
patch([t1 fliplr(t1)], [V_Out2 fliplr(V_Out3)], 'r', 'FaceAlpha',0.1, 'EdgeColor','none') % V_Out2 & V_Out3
patch([t2 fliplr(t2)], [V_Out4 fliplr(V_Out6)], 'g', 'FaceAlpha',0.1, 'EdgeColor','none') % V_Out4 & V_Out6
so the complete code is now:
t1 = linspace(-108000,-5000,500);
t2 = linspace(5000,108000,500);
U_c1 = 4.75;
U_c2 = 5;
U_c3 = 5.25;
V_o = 2.5;
G = 6.667*10^(-3);
I_p11 = t1/399;
I_p12 = t2/399;
V_Out1 = (U_c1/5)*(V_o+G*I_p11);
V_Out2 = (U_c2/5)*(V_o+G*I_p11);
V_Out3 = (U_c3/5)*(V_o+G*I_p11);
V_Out4 = (U_c1/5)*(V_o+G*I_p12);
V_Out5 = (U_c2/5)*(V_o+G*I_p12);
V_Out6 = (U_c3/5)*(V_o+G*I_p12);
plot(t1,V_Out1,'c--');
hold on
plot(t1,V_Out2, 'g:');
plot(t1,V_Out3, 'b-.');
plot(t2,V_Out4,'c--');
plot(t2,V_Out5, 'g:');
plot(t2,V_Out6, 'b-.');
patch([t1 fliplr(t1)], [V_Out2 fliplr(V_Out3)], 'r', 'FaceAlpha',0.1, 'EdgeColor','none') % V_Out2 & V_Out3
patch([t2 fliplr(t2)], [V_Out4 fliplr(V_Out6)], 'g', 'FaceAlpha',0.1, 'EdgeColor','none') % V_Out4 & V_Out6
hold off
xlabel('Power in W');
ylabel('V_O_u_t');
legend('V_O_u_t_1','V_O_u_t_2', 'V_O_u_t_3');
Make appropriate changes to get the result you want.
0 Comments
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!