standard deviation of all elements of an array in MATLAB?

0

How to calculate the standard deviation of all the elements of an array?

The std function divides by column. How do you calculate for all elements?

    
asked by anonymous 03.11.2018 / 19:06

2 answers

1

Given a a array, you can always access all elements using a(:) .

Example:

a=magic(3)
a =
     8     1     6
     3     5     7
     4     9     2

a(:)
ans =
     8
     3
     4
     1
     5
     9
     6
     7
     2

In your case, just use std(a(:)) or instead of std(a) .

    
05.11.2018 / 12:59
1
soma = 0;
soma = a(:,:) + soma; %Basta informar as dimensões da matriz

n = size(a);
media = (soma / n);
s = 0;

% a fórmula de desvio padrão deve ser conferida e testada. 

for i = 1: n

   s = (( a(x) - media )^2)
end

s = ( ( s / (n-1) ) ^ 0.5 ) 
    
05.11.2018 / 13:37