Fill out Plot between V_Out1 and V_Out3

4 visualizaciones (últimos 30 días)
Daniel Senst
Daniel Senst el 14 de Mayo de 2020
Comentada: darova el 17 de Mayo de 2020
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 comentarios
darova
darova el 14 de Mayo de 2020
Please attach the code using this button
Show the result you want to get
Daniel Senst
Daniel Senst el 17 de Mayo de 2020
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-.');
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');
The area between V_Out1 and V_Out 3 as well as V_Out 4 and V_Out 6 should be filled out by a color. I tried it with the fill() command, but that didn't work for me

Iniciar sesión para comentar.

Respuestas (2)

darova
darova el 17 de Mayo de 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 comentario
darova
darova el 17 de Mayo de 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')

Iniciar sesión para comentar.


Star Strider
Star Strider el 17 de Mayo de 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.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by