Is it possible to change solid fill to lines for patch and set limits to patch?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to fill the area between the z line and v line from from 0 until when they cross at 0.725 and cannot get the function to stop filling the area at that point. Does this require a loop or is there an easier way to do this? I also was wondering if it is possible to change the fill from being a solid fill to just a line pattern going diagonally through the area or if it has to be solid.
clear all
close all
clc
% V ideal
y = 0:10:35000;
x = 0:.01:0.9;
y = 14490 .* log( 1 ./ (1 - x));
% n max
z = 0:1:35000;
b = 0:0.01:0.9;
z = 14490 .* (log( 1 ./ (1 - b)) - ( 0.25 ) .* ( b ./ (1-b)));
% n = 1.1
v = 0:1:35000;
b = 0:0.01:0.9;
v = 14490 .* (log( 1 ./ (1 - b)) - (( 0.9091 ) .* b));
hold on
% All Functions Plotted
plot(x,y,'g');
plot(b,z,'r');
plot(b,v);
% Fill Area
patch([b fliplr(b)],[z fliplr(v)],'b')
% Labeling the Plot
title('\DeltaV vs. m_p/m_0')
xlabel('m_p/m_0')
ylabel('\DeltaV')
label1 = '\DeltaV Ideal';
label2 = '\eta_{max} = 4';
label3 = '\eta = 1.1';
legend(label1,label2,label3,'interpreter','tex')
hold off
0 Kommentare
Antworten (1)
DGM
am 26 Feb. 2022
You should be able to just limit the range used for drawing the patch object
% V ideal
y = 0:10:35000;
x = 0:.01:0.9;
y = 14490 .* log( 1 ./ (1 - x));
% n max
z = 0:1:35000;
b = 0:0.01:0.9;
z = 14490 .* (log( 1 ./ (1 - b)) - ( 0.25 ) .* ( b ./ (1-b)));
% n = 1.1
v = 0:1:35000;
b = 0:0.01:0.9;
v = 14490 .* (log( 1 ./ (1 - b)) - (( 0.9091 ) .* b));
% All Functions Plotted
hold on
plot(x,y,'g');
plot(b,z,'r');
plot(b,v);
% Fill Area
idx = find(b==0.72);
patch([b(1:idx) fliplr(b(1:idx))],[z(1:idx) fliplr(v(1:idx))],'b')
I haven't tried it, but this FEX submission appears to do hatch fills for patch objects:
2 Kommentare
DGM
am 26 Feb. 2022
I chose the closest defined x-value. b has no value at 0.725. If you want to make sure the patch extends to the intersection, you'll have to insert an extra point (or make sure b and z actually have a point defined at that location).
% Fill Area
idx = find(b==0.72); % the closest x-value not beyond the intersection
xint = 0.724877; % this is still approximate
yint = interp1(b,z,xint);
patch([b(1:idx) xint fliplr(b(1:idx))],[z(1:idx) yint fliplr(v(1:idx))],'b')
I didn't expect the small gap to be an issue if you were to use a hatch fill anyway.
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!