mean and peak for all sample
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
this code for one sample :
[M,I] = max(pz3,[],2);
Msg=sprintf('peak is %f and it is locatedat %i index of the array\n ',z(I(1)),I(1));
disp(Msg);
M1 = sum(z.*pz3(1,:))/sum(pz3(1,:)) ;
Msg=sprintf('mean value is %f \n ',M1);
disp(Msg);
how I can generalize it to the entire sample?
0 Kommentare
Antworten (1)
DGM
am 25 Mai 2021
What is "the entire sample"? Is it the entirety of pz3? Is it each row? Is it z.*pz3?
I'm going to just assume that you want to find the max and mean of a 2D array called A.
A = rand(10)
The mean is simple:
mn = mean(A(:))
If you want the global maximum and the linear index:
[mx idx] = max(A(:))
If you want subscripts instead of a linear index:
[suby subx] = ind2sub(size(A),idx)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!