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

조회 수: 3 (최근 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