Filling the area between two open ended curves

2 visualizaciones (últimos 30 días)
sa ab
sa ab el 29 de Feb. de 2020
Comentada: darova el 29 de Feb. de 2020
I want to fill the area between the curves as shown in the attached picture. I tried fliplr and flipud, it does not work. Also I tried the below function and it still gives me a wrong output.
function val=area_col(fname)
p=load(fname);
x=p(:,1);
y1=p(:,2);
y2=p(:,3);
fx=[x x(end:0:1)];
fy=[y1 y2(end:0:1)];
figure
hold on
plot(x,y1);
plot(x,y2);
fill_color=[.929 .694 .125];
fh=fill(fx,fy,fill_color);
hold off
Thank you very much for any support.
  4 comentarios
sa ab
sa ab el 29 de Feb. de 2020
Thank you Darova, I tried and yieled the below graph, which actually it not what I want. I attached my data as well.
p=load('L_D copy.txt');
x=p(:,1);
y1=p(:,2);
y2=p(:,3);
fx=[x x(end:-1:1)];
fy=[y1 y2(end:-1:1)];
figure
hold on
plot(x,y1);
plot(x,y2);
fill_color=[.929 .694 .125];
fh=fill(fx,fy,fill_color);
hold off
Thank you very much in advance!
darova
darova el 29 de Feb. de 2020
Because of concatenating

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 29 de Feb. de 2020
Try this:
p = load('L_D copy.txt');
x = p(:,1);
y1 = p(:,2);
y2 = p(:,3);
figure
plot(x, y1, x, y2)
hold on
fill_color=[.929 .694 .125];
patch([x; flipud(x)], [y1; flipud(y2)], fill_color)
hold off
producing:

Más respuestas (0)

Categorías

Más información sobre Graphics Performance 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!

Translated by