Filter löschen
Filter löschen

Patch Between two curves that are not functions. Crosses over

6 Ansichten (letzte 30 Tage)
I am having trouble fillling the area between {x1, y1} and {x2, y2} without it crossing over. Ideally it should be a filled Elbow shape without crossing over each other. I tried patch and fill functions and I get similair behavior.
x1 = [1 1 1 2.5 5];
y1 = [5 2.5 1 1 1];
x2 = [2 2 5];
y2 = [5 2 2];
hold on
plot(x1, y1, LineStyle=":");
plot(x2, y2, LineStyle=":");
xlim([0, 6])
ylim([0, 6])
fill([x1, x2], [y1, y2], 'k', 'FaceAlpha',0.2)
hold off

Akzeptierte Antwort

Star Strider
Star Strider am 14 Sep. 2023
Perhaps this —
x1 = [1 1 1 2.5 5];
y1 = [5 2.5 1 1 1];
x2 = [2 2 5];
y2 = [5 2 2];
figure
hold on
plot(x1, y1, LineStyle=":");
plot(x2, y2, LineStyle=":");
xlim([0, 6])
ylim([0, 6])
patch([x1 flip(x2)], [y1 flip(y2)], [1 1 1]*0.5, 'EdgeColor','none')
% fill([x1, x2], [y1, y2], 'k', 'FaceAlpha',0.2)
hold off
The patch function fills a closed region, defined by its arguments. If you want to fill between the lines, that is relatively straightforward.
.

Weitere Antworten (0)

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by