Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

fill comand in functions

조회 수: 1 (최근 30일)
felix jose chavez torres
felix jose chavez torres 2017년 9월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
¿how can i get fill just this area?

답변 (1개)

Star Strider
Star Strider 2017년 9월 4일
Try this:
x = linspace(0, 6, 500);
upper_curve = sqrt(x);
lower_curve = x.^2 - 3;
idx = (upper_curve >= lower_curve) & (upper_curve >= 0);
figure(1)
plot(x, upper_curve, '-k', x, lower_curve, '-k')
hold on
patch([x(idx) fliplr(x(idx))], [upper_curve(idx) fliplr(max([lower_curve(idx); zeros(1,nnz(idx))]))], 'g')
hold off
axis([-1 6 -6 6])
grid
The logic and approach are the same as with your previous Question, with the addition of the logic defining the lower border. That is the maximum of either zero or the lower curve. That begins as a (2xN) matrix of a (1xN) vector of zeros and a (1xN) vector describing the lower curve. The max function creates a row vector of the maximum of each column, producing a vector that is the maximium of zero or the value of the lower curve at each ‘x’ value (defined in the first argument to the patch function here).

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by