MATLAB Answers

Shade the region above the graph

2 views (last 30 days)
Sasha Gomes
Sasha Gomes on 21 Sep 2020
Commented: Star Strider on 21 Sep 2020
I am trying to shade the region to above the graph. Does anyone know how to go about doing that? It would be a great help.
Thanks
My code is attached below
% Maximum speed
rho = 0.002378; % at sea level
Vmax = 987.48;
K = 0.0397887;
rho30 = 0.00089;
rhos = 0.374; % sigma
WS = 0:0.1:160;
TWvmax = ((1.23488./WS)+(0.000414*WS));
plot(WS,TWvmax,'--r')
hold on
text(60,-0.01,'Maximum speed')

  0 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 21 Sep 2020
Try this:
% Maximum speed
rho = 0.002378; % at sea level
Vmax = 987.48;
K = 0.0397887;
rho30 = 0.00089;
rhos = 0.374; % sigma
WS = 0:0.1:160;
TWvmax = ((1.23488./WS)+(0.000414*WS));
plot(WS,TWvmax,'--r')
hold on
ixf = isfinite(TWvmax);
patch([WS(ixf) fliplr(WS(ixf))], [TWvmax(ixf) ones(size(TWvmax(ixf)))*max(TWvmax(ixf))], 'b', 'EdgeColor','none', 'FaceAlpha',0.5)
hold off
text(60,-0.01,'Maximum speed')
ylim([-1 max(ylim)])
Note that ‘TWvmax’ contains at least one infinite value, so it is necessasry to eliminate it to draw the patch object.
.

  3 Comments

Star Strider
Star Strider on 21 Sep 2020
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!