I would like to create a graph similar to this one: (I already know the Mathematical function)
I can draw the function, but to color the right side and left side was for me hard to achieve.
Anybody has an Idea how can I do that?!

 채택된 답변

SSM
SSM 2021년 3월 26일
편집: SSM 2021년 3월 26일

0 개 추천

Use the patch() function.
Example:
%%% Create sample data
x = 0:1:100;
y = sin(x);
plot(x,y)
patch([x fliplr(x)], [y max(ylim)*ones(size(y))], 'r') %%% Patch the area above the sine curve red
patch([x fliplr(x)], [y min(ylim)*ones(size(y))], 'r') %%% Patch the area below the sine cutve blue
legend() %%% Add the legend here

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Networks에 대해 자세히 알아보기

질문:

2021년 3월 26일

편집:

SSM
2021년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by