필터 지우기
필터 지우기

I am not able to fill with the color between 2 lines in matlab

조회 수: 3 (최근 30일)
Sahil Wani
Sahil Wani 2023년 1월 6일
댓글: Voss 2023년 1월 7일
% I am not able to fill with the colour between 2 lines (y1 and y2) in Matlab. The Matlab code is attached as follows:
close
x = (0:60)';
y1 = 0.5025*exp(0.0471*x); y2=0.2045*exp(0.02*x);
hold all
plot(x,y1)
plot(x,y2)
patch([x fliplr(x)], [y1 fliplr(y2)], 'c','EdgeColor','none', 'FaceAlpha',0.25)

답변 (1개)

Voss
Voss 2023년 1월 6일
Since x (and consequently y1 and y2) are column vectors, using fliplr does not have the desired effect. Instead you can use flipud or the more general flip. And use vertical concatentation (i.e., [x; flip(x)]) rather than horizontal concatenation (i.e., [x flip(x)]).
close
x = (0:60)';
y1 = 0.5025*exp(0.0471*x); y2=0.2045*exp(0.02*x);
hold all
plot(x,y1)
plot(x,y2)
patch([x; flip(x)], [y1; flip(y2)], 'c','EdgeColor','none', 'FaceAlpha',0.25)
  댓글 수: 1
Voss
Voss 2023년 1월 7일
@Sahil WANI: Any questions, please let me know. Otherwise, please "Accept This Answer". Thanks!

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by