# How to patch upperbound and lowerbound

조회 수: 2(최근 30일)
alpedhuez 2021년 8월 23일
댓글: Star Strider 2021년 8월 23일
But I am not yet sure of how it works. (Partly due to the fact that https://www.mathworks.com/help/matlab/ref/patch.html only has graphic examples.)
Suppose I have
plot(T.date,upperbound)
hold on
plot(T.date,lowerbound)
Then how can one fill in upperbound and lowerbound?
##### 댓글 수: 1표시숨기기 없음
alpedhuez 2021년 8월 23일
I have tried https://www.mathworks.com/matlabcentral/answers/180829-shade-area-between-graphs but does not seem to work. Maybe it is because x axis is a datetimie variable?

댓글을 달려면 로그인하십시오.

### 채택된 답변

Star Strider 2021년 8월 23일
Try something like this —
T = table(datetime('now')+days(1:14).', rand(14,1), rand (14,1)+1, 'VariableNames',{'date','lowerbound','upperbound'})
T = 14×3 table
date lowerbound upperbound ____________________ __________ __________ 24-Aug-2021 15:54:18 0.3007 1.7723 25-Aug-2021 15:54:18 0.68026 1.703 26-Aug-2021 15:54:18 0.4398 1.6127 27-Aug-2021 15:54:18 0.62549 1.237 28-Aug-2021 15:54:18 0.44381 1.6517 29-Aug-2021 15:54:18 0.71737 1.3115 30-Aug-2021 15:54:18 0.41553 1.1505 31-Aug-2021 15:54:18 0.56936 1.405 01-Sep-2021 15:54:18 0.064302 1.329 02-Sep-2021 15:54:18 0.85725 1.5955 03-Sep-2021 15:54:18 0.15449 1.7525 04-Sep-2021 15:54:18 0.91195 1.8573 05-Sep-2021 15:54:18 0.10671 1.4731 06-Sep-2021 15:54:18 0.41436 1.6558
figure
patch([T.date; flipud(T.date)], [T.lowerbound; flipud(T.upperbound)], 'r', 'FaceAlpha',0.5)
grid
The patch function until recently did not work with datetime arrays, so it was necessary to use fill instead, with the same syntax as demonstrated here.
.
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Star Strider 2021년 8월 23일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by