Problem with fill()/patch() between two lines in R2023a
Afficher commentaires plus anciens
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 commentaire
Stephen23
le 2 Nov 2023
Have a think about what FLIPLR does to a column vector.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

