whats wrong with the code
조회 수: 1 (최근 30일)
이전 댓글 표시
this is the code to calculate itakura saito distance between two psd. ans should be d but d contains all elements as NaN plss help
[nf1,p2]=size(pf1);
p1=p2-1;
nf2=size(pf2,1);
if nargin<3 | isempty(mode)
mode='0';
end
if any(mode=='d') | (mode~='x' & nf1==nf2)
nx=min(nf1,nf2);
r=pf1(1:nx,:)./pf2(1:nx,:);
q=log(r);
d=log((sum(r(:,2:p1),2)+0.5 * ...
(r(:,1)+r(:,p2)))/p1)-(sum(q(:,2:p1),2)+0.5* ...
(q(:,1)+q(:,p2)))/p1;
else
r=permute(pf1(:,:,ones(1,nf2)),[1 3 2])./permute(pf2(:,:,ones(1,nf1)),[3 1 2]);
q=log(r);
d=log((sum(r(:,:,2:p1),3)+0.5 * ...
(r(:,:,1)+r(:,:,p2)))/p1)-(sum(q(:,:,2:p1),3)+0.5* ...
(q(:,:,1)+q(:,:,p2)))/p1;
end
댓글 수: 2
Jan
2012년 4월 1일
Please learn how to format the code by reading the "Markup help" link on this page.
Fine. This is the thousands time I've written this suggestion.
답변 (1개)
Image Analyst
2012년 4월 1일
Just taking a stab in the dark (because I have no idea what this code does), I set
pf1 = rand(10);
pf2 = rand(10);
% And because mode is a reserved function
% that you don't want to override,
% I changed mode to myMode:
myMode = 'x';
and it ran fine with d NOT being all nans.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!