Hatching a region between two functions
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have a set of data, I calculated the min and the max and the average and then I want to plot the average and hatch the area which is between max and min.
I attach here the data, the process for creating the function superior, inferior and average.
I found a way in the MuPad but I do not know it and I would like to use the Matlab.
If someone has any suggstions or ideas, please let me know.
Cheers, Antonio
for the sake of simpleness, in the table attached the first column is absscissa, the second the minimum the third is maximum which take respectively the names X as the abscissas F as the minimum, G as the maximum
hold on;
pF=polyfit(X,F,9); pG=polyfit(X,G,9);
f=polyval(pF,X); g=polyval(pG,X);
plot(X,F,'o',X,f,'-') plot(X,G,'o',X,g,'-')
-0.0105856 0.0567304 0.304696
-0.0109566 0.0541681 0.29648
-0.0114274 0.0527631 0.285055
-0.0119611 0.0526772 0.280862
-0.0124948 0.0509386 0.271505
-0.0130284 0.0504875 0.27002
-0.0135621 0.0479437 0.263591
-0.0140958 0.0464733 0.260301
-0.0146442 0.0436699 0.251154
-0.0152616 0.0419518 0.249578
-0.0159151 0.0403968 0.246156
-0.0165686 0.0376205 0.232884
-0.0172221 0.0358952 0.228482
-0.0178756 0.0347101 0.226353
-0.0185054 0.0337404 0.222677
-0.0191351 0.0328784 0.220499
-0.0197648 0.0321577 0.217536
-0.0203945 0.0310619 0.214267
-0.0210243 0.0287334 0.210937
-0.021654 0.0265714 0.207631
-0.0222837 0.0245878 0.204379
-0.0229134 0.0227951 0.201215
-0.0235431 0.0211813 0.198121
-0.0241729 0.0197453 0.195137
-0.0248026 0.018475 0.192246
-0.0254323 0.0173415 0.189424
-0.026062 0.0163494 0.186684
-0.0266917 0.0154906 0.18404
-0.0273215 0.0147535 0.181488
-0.0279512 0.0141141 0.179007
-0.0285809 0.0135698 0.176605
-0.0292106 0.0131054 0.174274
-0.0298404 0.0127084 0.172007
-0.0304701 0.0123768 0.169787
-0.0310998 0.0121053 0.167632
-0.0317295 0.0118886 0.165537
-0.0323592 0.0117176 0.163502
-0.032989 0.0115901 0.161514
-0.0336187 0.0115108 0.159586
-0.0342484 0.0114732 0.157709
-0.0348781 0.0114712 0.155865
-0.0355079 0.0114983 0.154072
-0.0361376 0.011561 0.152337
-0.0367673 0.0116436 0.150637
-0.037397 0.01174 0.148972
-0.0380267 0.0118431 0.147328
-0.0386565 0.0119501 0.145712
-0.0392862 0.0120604 0.144137
-0.0399159 0.0121648 0.142596
-0.0405456 0.012252 0.141086
-0.0411754 0.0123101 0.139615
-0.0418051 0.0123372 0.138163
-0.0424348 0.012314 0.136731
-0.0430645 0.0122229 0.13533
I need to plot the hatch between the minimum and the maximum.
Thank you very much.
0 commentaires
Réponse acceptée
Andrew Newell
le 18 Juil 2011
To fill the region between lines with a color, you could use a command like
patch([x; flipud(x)],[f; flipud(g)],'r')
The reason for the flipud is to make a round trip around the surface by going forwards on the bottom and backwards on the top.
If you would rather the fill be a hatch pattern, you'll need to download one of the File Exchange packages like Hatch fill patterns plus plus and read the documentation.
4 commentaires
Plus de réponses (1)
Sean de Wolski
le 18 Juil 2011
And what do you know - a selection of hatch functions were selected for Pick of the Week this past weak!
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!