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!