mean and peak for all sample
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
DGM
el 25 de Mayo de 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)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!