声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1685|回复: 3

[综合讨论] 请教这个程序

[复制链接]
发表于 2007-5-21 22:41 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
已有程序如下:
function [recogRate, absAveError, correctCount, pitchCount]=pvSimilarity(cPitch, tPitch, pitchTol, plotOpt)
% pvSimilarity: Similarity between two pitch vectors

if nargin<1, selfdemo; return; end
if nargin<4, plotOpt=0; end

cPitch=cPitch(:);
tPitch=tPitch(:);
absDiff=abs(cPitch-tPitch);
nonZeroIndex=(cPitch~=0) & (tPitch~=0);
outOfBoundIndex=absDiff>pitchTol;
errorIndex=nonZeroIndex & outOfBoundIndex;
errorCount=sum(errorIndex);
absAveError=mean(absDiff(nonZeroIndex));
pitchCount=sum(nonZeroIndex);
correctCount=pitchCount-errorCount;
recogRate=correctCount/pitchCount;

if plotOpt
        pitchNum=length(tPitch);
        tPitch(tPitch==0)=nan;
        plot(1:pitchNum, cPitch, 'o-g', 1:pitchNum, tPitch, '.-k');
        index=find(errorIndex);
        line(index, cPitch(index), 'marker', 'x', 'linestyle', 'none', 'color', 'r');
        grid on;
        legend('Computed pitch', 'Target pitch');
        xlabel(sprintf('recogRate=%g%%, pitchTol=%g, correctCount=%d, pitchCount=%d', recogRate*100, pitchTol, correctCount, pitchCount));
end

% ====== Self demo
function selfdemo
cPitch=[97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 56.9352 56.6997 56.9352 57.174 58.6804 58.1635 97.5248 97.5248 97.5248 97.5248 63.4868 63.4868 62.8078 60.6214 59.7627 58.1635 58.1635 58.1635 57.6617 49.5248 49.3709 61.2184 48.6214 48.4753 48.4753 49.2184 61.5248 59.7627 72.3304 72.9173 93.174 93.174 58.42 56.238 54.3004 54.3004 54.3004 54.7126 56.0117 57.174 57.9108 60.3304 59.7627 58.6804 57.4161 56.4673 55.7883 55.5677 56.0117 56.4673 56.4673 56.6997 58.1635 58.9447 58.42 58.1635 56.6997 56.0117 56.0117 56.6997 55.5677 57.174 57.6617 57.6617 57.6617 56.9352 55.5677 55.35 55.7883 56.0117 56.0117 56.0117 56.0117 56.4673 56.4673 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248 97.5248];
tPitch=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 58.680365 56.9352 56.699654 56.9352 57.173995 58.420025 57.910801 0 0 0 0 0 63.486821 62.478049 60.917323 59.485736 58.420025 58.163541 58.163541 57.661699 0 0 61.218415 60.621378 60.330408 60.621378 61.218415 61.524836 0 0 0 0 60.917323 58.944681 55.788268 54.300404 54.300404 54.505286 54.922471 55.788268 56.9352 57.910801 59.762739 59.485736 58.420025 57.416129 56.699654 56.011656 55.567726 56.237965 56.467271 56.467271 56.9352 58.163541 58.944681 58.680365 58.163541 56.9352 56.237965 56.011656 56.467271 55.567726 0 0 0 58.163541 56.699654 55.567726 55.349958 55.788268 56.011656 55.788268 56.011656 56.011656 56.467271 56.467271 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0];
pitchTol=1;
plotOpt=1;
feval(mfilename, cPitch, tPitch, pitchTol, plotOpt);
有没有好心人能帮忙解释一下这个程序,小女子在此谢谢了!
回复
分享到:

使用道具 举报

发表于 2007-5-22 16:19 | 显示全部楼层
解释程序,也要说哪个地方不懂啊? 不会是  ……………………
 楼主| 发表于 2007-5-23 10:04 | 显示全部楼层
就是大概流程是怎样的?我实在是看不懂,只要好心人大概说下,我也比较好研究下去啊,不好意思本人比较笨,总是要有人引导..
发表于 2007-5-23 10:17 | 显示全部楼层
原帖由 yomican 于 2007-5-23 10:04 发表
就是大概流程是怎样的?我实在是看不懂,只要好心人大概说下,我也比较好研究下去啊,不好意思本人比较笨,总是要有人引导..


笨不会是永远,聪明也不会是必然,每个人都经历过这个阶段,况且,对于别人的代码来说,任何人都是头痛的,也不会有太多的精力
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-19 04:18 , Processed in 0.065182 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表