Shaded Standard Deviation Corridors
Mostrar comentarios más antiguos
Hi,
Here is my code for my work and my data is already set up in columns on excel. The problem I'm getting is that my standard devation corridors are not filling up with the desired colors for both plots. Why might that be so? Attached is my code and the result of it. Thanks for your help in advance.
k
%Variance Corridor:
dataset=xlsread('Book1.xlsx', 'Sheet1')
tensile_stress = dataset(:,1); % your mean stress;
tensile_strain = dataset(:,2); % your mean strain;
std_dev_tensile_stress = dataset(:,3); % your std of stress;
surrogate_stress=dataset(:,4); % mean surrogate stress
surrogate_strain=dataset(:,5); % mean surrogate strain
std_dev_surrogate_stress=dataset(:,6); % surrogate std
x = tensile_strain;
y = tensile_stress;
sd = std_dev_tensile_stress;
x1=surrogate_strain
y1=surrogate_stress
sd1=std_dev_surrogate_stress
figure
patch([x; flipud(x)], [y-sd; flipud(y+sd)], [1,1,0]);
hold on
plot(x,y);
hold on
patch([x1; flipud(x1)], [y1-sd1; flipud(y1+sd1)], [0,1,1]);
hold on
plot(x1,y1);
hold off
Respuesta aceptada
Más respuestas (2)
It's because the last three values of x and y are NaN.
dataset=xlsread('Book1.xlsx', 'Sheet1');
tensile_stress = dataset(:,1); % your mean stress;
tensile_strain = dataset(:,2); % your mean strain;
std_dev_tensile_stress = dataset(:,3); % your std of stress;
surrogate_stress=dataset(:,4); % mean surrogate stress
surrogate_strain=dataset(:,5); % mean surrogate strain
std_dev_surrogate_stress=dataset(:,6); % surrogate std
x = tensile_strain;
y = tensile_stress;
sd = std_dev_tensile_stress;
x1 = surrogate_strain;
y1 = surrogate_stress;
sd1 = std_dev_surrogate_stress;
figure
hold on
patch([x(1:24); flipud(x(1:24))], [y(1:24)-sd(1:24); flipud(y(1:24)+sd(1:24))], [1,1,0]);
plot(x,y);
patch([x1; flipud(x1)], [y1-sd1; flipud(y1+sd1)], [0,1,1]);
plot(x1,y1);
hold off
1 comentario
Kev
el 19 de Sept. de 2021
Sulaymon Eshkabilov
el 19 de Sept. de 2021
Editada: Sulaymon Eshkabilov
el 19 de Sept. de 2021
In your data, there are some missing data points (x, y, std) which must be removed and then everything works ok. Here is the corrected part of the code:
...
figure
A = [x; flipud(x)];
B = [y-sd; flipud(y+sd)];
IDX = isnan(A);
A(IDX)=[];
B(IDX)=[];
patch(A,B, [1,1,0]);
hold on
plot(x,y);
...
Categorías
Más información sobre Stress and Strain en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

