Domanda

i have a small problem. i have plotted standard deviation using matlab for a very large matrix. the matrix contains: 24x45x65 --->> hours x days x customers i plotted the standard deviation and standard error. But it only shows me 1 standard devation away..what if i want to see 3 or 6 standard deviation away..is it possible to tweak the code to get it ??

code:

xwkd = x_weekday;
for k2 = 1:size(xwkd,1)
    hrmx = xwkd(k2,:,1:64);            % All data for hour ‘k1’
   hrmn(k2) = trimmean(hrmx(:),0.05);       % Mean
    hrsd(k2) = std(hrmx(:));        % Standard deviation
end
N = numel(hrmx);
figure(2)                           % Plot Mean ± Standard Deviation
errorbar([1:24], hrmn, hrsd)
hold on
grid
xlabel('Hour')
ylabel('kWh ± SD') 
figure(3)                           % Plot Mean ± Standard Error
errorbar([1:24], hrmn, hrsd/sqrt(N))
hold on
grid
xlabel('Hour')
ylabel('kWh ± SE')

the data: x_weekday.mat

thank you guys alot

È stato utile?

Soluzione

You set the error bar extents with the 3rd and 4th arguments to the errorbar function. So instead of just giving the standard deviation you can set the limits specifically for example:

nSD=3; % number of standard deviations to show
errorbar(X,Y,Y-nSD*SD,Y+nSD*SD);

Or as used in the OP's question the 3rd input can be used alone to set the standard deviation, in which case the function uses [Y-SD,Y+SD] as the error bar extents,

So the above is actually the same as just telling the function the standard deviation is increased by a factor of nSD so a silmpler alternative would be to use:

errorbar(X,Y,nSD*SD)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top