stepwise mean value of array
Ältere Kommentare anzeigen
Hi!
% a= [1 2 5 6 4 7......]
how to get the mean value :
mean_a =[mean(a(1),a(110)),mean(a(2),a(120)), mean(a(3),a(130))............]
thanky
2 Kommentare
Image Analyst
am 14 Nov. 2012
What do you mean by mean(a(1),a(110))? Is that the mean of all elements from 1 to 110, like this: mean(a(1:110))?
Rica
am 14 Nov. 2012
Akzeptierte Antwort
Weitere Antworten (3)
Dian Permatasari
am 14 Nov. 2012
if the calculation of some matrix, you can use:
B=mean([A(1) A(2) A(3) ...])
Walter Roberson
am 14 Nov. 2012
N = 7; %or as appropriate
LB = 1 : N; %the lower bounds for the means
UB = (1:N)*100; %or as appropriate for the upper bound
S = cumsum(a); %the trick!
mean_a = (S(UB) - S(LB)) ./ (UB - LB + 1);
Andrei Bobrov
am 14 Nov. 2012
Bearbeitet: Andrei Bobrov
am 14 Nov. 2012
"...the mean value of element 1 and element 100, and the mean value of element 2 and element 200 an so on..." :
k = 100:100:numel(a);
mean_a = mean(a([(1:numel(k))', k']),2);
Kategorien
Mehr zu Creating and Concatenating Matrices 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!