Effacer les filtres
Effacer les filtres

plot standard deviation as a shaded area

894 vues (au cours des 30 derniers jours)
Hinna Ahmed
Hinna Ahmed le 3 Déc 2019
Modifié(e) : M le 3 Déc 2019
Hey,
I have a vector containing the mean values and a another vector with the standard deviations. I want to plot the standard deviation as a shaded area and the mean as a line as shown on the image below but I want to write my own function. hope someone can help
stdshade.PNG
  2 commentaires
M
M le 3 Déc 2019
I want to write my own function
Does this mean you do not want to use built-in function like fill or area ?
You can start by reading this discussion:
https://mathworks.com/matlabcentral/answers/180829-shade-area-between-graphs
Hinna Ahmed
Hinna Ahmed le 3 Déc 2019
I want to use built-in functions like fill or area but not functions like stdshade because they use a matrix with all the observations as a input but i have already calculated the mean and std.

Connectez-vous pour commenter.

Réponses (1)

M
M le 3 Déc 2019
Modifié(e) : M le 3 Déc 2019
You can use the code directly from this answer:
y = rand(1,10); % your mean vector;
x = 1:numel(y);
std_dev = 1;
curve1 = y + std_dev;
curve2 = y - std_dev;
x2 = [x, fliplr(x)];
inBetween = [curve1, fliplr(curve2)];
fill(x2, inBetween, 'g');
hold on;
plot(x, y, 'r', 'LineWidth', 2);

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by