mean and peak for all sample
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
DGM
il 25 Mag 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)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!