how to fill between 2 graphs
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
halil hasan
el 10 de Abr. de 2020
Comentada: Les Beckham
el 14 de Abr. de 2020
Hi eveybody
I could not fill the gap betwween 2 curves. it is shown in below figure.
can anyone help me?
thanks
The code I used is:
plot(KI1,KP1);
xlabel('K_I');
ylabel('K_P');
grid on
hold on
x2=zeros(1,150)
y=linspace(-20,40,numel(x2))
plot(x2,y,'linewidth',2)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283471/image.jpeg)
6 comentarios
Respuesta aceptada
Les Beckham
el 11 de Abr. de 2020
What do you mean by "fill the gap"? Do you want to connect the start and end points so that this becomes a closed curve? If so, this should do it:
plot([KI1(:); KI1(1)], [KP1(:); KP1(1)]);
xlabel('K_I');
ylabel('K_P');
grid on
7 comentarios
Más respuestas (1)
darova
el 13 de Abr. de 2020
Here is my shot
y = 0:0.1:pi;
x1 = -sin(y);
x2 = y*0-0.3;
[xc,yc] = polyxpoly(x1,y,x2,y);
xx = [xc(1) x1(x1<x2) xc(end)];
yy = [yc(1) y(x1<x2) yc(end)];
plot(x1,y,x2,y)
patch(xx,yy,'r')
line(xc,yc,'marker','o')
success?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/284104/image.png)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!