Trying to use patch to fill between two lines but no shading due to empty double row vector?

7 次查看(过去 30 天)
I am trying to shade between z and v up to 0.725 but it just returns
idx =
1×0 empty double row vector
How do I get this to shade the space?
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
idx = find(b==0.725)
patch([b(1:idx) fliplr(b(1:idx))],[z(1:idx) fliplr(v(1:idx))],'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

回答(1 个)

DGM
DGM 2022-2-26
That's because there is no x-value at that location due to its step size. See the comment on the prior question.

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by