Shaded Standard Deviation Corridors
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (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 Kommentar
Kev
am 19 Sep. 2021
Sulaymon Eshkabilov
am 19 Sep. 2021
Bearbeitet: Sulaymon Eshkabilov
am 19 Sep. 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);
...
Kategorien
Mehr zu Stress and Strain finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

