Info
此问题已关闭。 请重新打开它进行编辑或回答。
formula implementation using det
2 次查看(过去 30 天)
显示 更早的评论
clc;
close all;
clear all;
A = [1 2 5 ; 4 4 6 ; 7 8 9];
[x1 x2]=gradient(A);
disp(x1);
disp('GRADIENT IN HORIZONTAL DIRECTION');
disp(x2);
disp('GRADIENT IN VERTICAL DIRECTION');
x=x1+x2;
disp(x);
C=cov(x);
disp(C);
l=det(C);
disp(l);
title('determinant');
S=sqrtm(l);
disp(S);
title('square root');
U=2*3.14*(2.1*2.1);
F=S/U;
whether i can use this way to implement sqrt(detCi)/(2*pi*h*h)..of my formula sir? Ci-covariance matrix of any input matrix
1 个评论
Oleg Komarov
2011-8-28
Please format the code: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup#answer_18099
回答(1 个)
Walter Roberson
2011-8-29
sqrtm() is not useful here: you might as well use sqrt() .
Watch out for the determinant being negative: that would give you a complex square root.
3.14 is completely inadequate as a representation of Pi: use the constant pi instead.
It isn't clear to me from your description of the problem what gradient has to do with the question?
2.1 appears to be a "magic number" in your code. What does it have to do with the "h"? of your formula?
Why be so verbose?
h_squared = (2.1).^2;
F = sqrt(det(cov(x)) ./ (2*pi*h_squared);
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!