Problem with fill()/patch() between two lines in R2023a
古いコメントを表示
I have a problem with the fill()/patch() command when plotting experimental data.
I want to plot a sine wave with an atan background, and i want to make a picture in which the filled region is the one between the two waves. However, when i attempt to fill() (or patch()) i get a straigth line going from the first to the last point in the functions i create, and i don't know how to avoid this.
What am i doing wrong?
Here is the code for the plot:
%define the variable
x = 0:0.05:6.28
x = transpose(x)
bg = atan(-x)
linetofill = sin(x)
bg
%plot raw spectrum
plot(x, linetofill)
hold on
%fill the lines up to the background contribution
fill([x fliplr(x)], [linetofill fliplr(bg)], 'cyan', "FaceAlpha", 0.5)
hold off
1 件のコメント
Stephen23
2023 年 11 月 2 日
Have a think about what FLIPLR does to a column vector.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

