finding skewness, kurtosis
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
This code does not give any result for skewness, kurtosis, and rms roughness. What is wrong with this simple snippet? Matlab does not give any error. M is a number matrix here.
function [avg, rms, sk, ku] = parameters(M)
rms=0;
k=0;
M=M(:);
% Average roughness
avg=mean(M);
for i = 1:numel(M)
% RMS roughness
k=sqrt((M(i)-mean(M))^2/numel(M));
rms=rms+k;
end
% skewness
sk=skewness(M);
% kurtosis
ku=kurtosis(M);
sprintf('%d', '%d', '%d', '%d', avg, rms, sk, ku);
2 comentarios
arun anoop m
el 23 de Nov. de 2017
X = randn([1 2]) y = skewness(X); ku=kurtosis(X); avg=mean(X); y ku avg
Image Analyst
el 23 de Nov. de 2017
Please, since this is an "Answer", NOT a comment asking for additional information, put it down in the Answers section with the rest of the answers, so you can get credit for it.
Respuestas (2)
Wayne King
el 8 de Abr. de 2012
Why do you have this line in your function:
sprintf('%d', '%d', '%d', '%d', avg, rms, sk, ku);
First of all those values will not be integers, so don't use %d
Your function outputs the arguments avg, rms, sk, and ku so remove that line from your function, run your function from the command line, and then you will see that you have variables: avg,rms,sk, and ku.
If you want, you can just remove the semicolon after sprintf in your function and it will print the values to the command window, but I don't think you need to do that (if you do that, do not use %d)
You can do something like:
sprintf('mean value is %2.3f\n',avg)
sprintf('RMS value is %2.3f\n',rms)
What values you use with %f depend on your data range.
But again, you output those values to the workspace.
2 comentarios
Image Analyst
el 8 de Abr. de 2012
Rod, I don't have whatever toolbox those functions are in.
I gave code for computing the third and fourth central moments (skew and kurtosis) of image intensitiess in http://www.mathworks.com/matlabcentral/answers/15307-image-operations-skewness-and-kurtosis>
But there is a difference between the moments with regard to intensity and the moments with regard to how the data is distributed spatially. You know the difference don't you? For example, consider two images, one with a Gaussian spot in the middle, and one with the Gaussian spot off-center. They will have the same intensity skewnesses but different spatial skewnesses. This is because the intensity skewness does not take location into account while the spatial skewness is like a moment of inertia (recall mechanics in your college physics class) and this of course depends on location. Just wanted to make sure you know the difference - if you already do, then just ignore what I said. Looks like you're after the intensity skewness, not the spatial skewness.
You didn't specify the problem but it's probably due to a display issue like Wayne pointed out. Otherwise you can use the debugger to set a breakpoint on the lines and examine the actual variables without regard to how they're printed out.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!