Info

此问题已关闭。 请重新打开它进行编辑或回答。

formula implementation using det

1 次查看(过去 30 天)
x
x 2011-8-28
关闭: MATLAB Answer Bot 2021-8-20
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
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
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);

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by