fill comand (functions)

2 次查看(过去 30 天)
how can i fill just this area in matlab? i need help.
  1 个评论
KSSV
KSSV 2017-9-4
provide the code which you have plotted this...

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2017-9-4
Try this:
x = linspace(-5, 5); % Define Indepenent Variable
upgoing_curve = x.^2; % Define First Curve
downgoing_curve = 5 - x.^2; % Define Second Curve
idx = (downgoing_curve > upgoing_curve) & (x >= 0); % Define Region-Of-Interest
figure(1)
plot(x, upgoing_curve, x, downgoing_curve, '-k');
hold on
patch([x(idx) fliplr(x(idx))], [upgoing_curve(idx) fliplr(downgoing_curve(idx))], 'g')
hold off
The patch call defines the independent variable and then flips it, and the dependent variables and flips the second one. The idea here is to create a closed curve, defined by ‘x(idx)’ and its ‘mirror image’, and the lower curve and the flipped version of the upper curve.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by