form 对话框
positive the_Index_of_Referenced_Tier_in_TextGrid 1
positive the_Number_of_Pitch_Points_in_a_Interval 10
endform
dirPath$="C:\temp\"
Create Strings as file list... list'dirPath$'\*.TextGrid
fileNum=Get number of strings
tierNum=the_Index_of_Referenced_Tier_in_TextGrid
pointNum=the_Number_of_Pitch_Points_in_a_Interval
for ifile to fileNum
select Strings list
fileName$=Get sting... ifile
newFileName$=fileName$-".TextGrid"
textGridFileName$=newFileName$+".TextGrid"
textGridFileName$=dirPath$+textGridFileName$
pitchTierFileName$=newFileName$+".PitchTier"
pitchTierFileName$=dirPath$+pitchTierFileName$
saveFileName$=newFileName$+"_Pitch.txt"
saveFileName$=dirPath$+saveFileName$
filedelete'saveFileName$'
fileappend'saveFileName$'文件名
fileappend'saveFileName$',
fileappend'saveFileName$'标注内容
fileappend'saveFileName$',
fileappend'saveFileName$'起点时间
fileappend'saveFileName$',
fileappend'saveFileName$'末点时间
fileappend'saveFileName$',
fileappend'saveFileName$'时长
fileappend'saveFileName$',
Read from file... 'pitchTierFileName$'
select PitchTier'newFileName$'
pitchPointNum=Get number of points
for pitchNum from 1 to pitchPointNum
pitchTime'pitchNum'=Get time from index... 'pitchNum'
endfor
pitchNum=pitchPointNum+1
pitchTime'pitchNum'=Get finishing time
Read from file... 'textGridFileName$'
select TextGrid'newFileName$'
dd=Is interval tier... 'tierNum'
if dd=1
intervalNum=Get number of intervals... 'tierNum'
endif
if dd=0
intervalNum=Get number of points... 'tierNum'
endif
begin Time0=0
endTime0=0
for interNum from 1 to intervalNum
if dd=1
labeName'interNum'$=Get label of interval... 'tierNum''interNum'
beginTime'interNum'=Get starting point... 'tierNum''interNum'
endTime'interNum'=Get end point... 'tierNum''interNum'
selLength'interNum'=endTime'interNum'-beginTime'interNum'
endif
if dd=0
labeName'interNum'$=Get label of point... 'tierNum''interNum'
xuhao='interNum'-1
beginTime'interNum'=endTime'xuhao'
endTime'interNum'=Get time point... 'tierNum''interNum'
selLength'interNum'=endTime'interNum'-beginTime'interNum'
endif
startPoint=1
pitchStartTime=0
pitchEndTime=0
startSel=0
sT=beginTime'interNum'
eT=endTime'interNum'
pitchStartTime'interNum'=0
pitchEndtTime'interNum'=0
for pitchNum from startPoint to pitchPointNum
if pitchTime'pitchNum'>sT and pitchTime'pitchNum'<=eT
startSel=startSel+1
if startSel=1
pitchStartTime'interNum'=pitchTime'pitchNum'
endif
pitchNextNum=pitchNum+1
pitchNextTime=pitchTime'pitchNextNum'
if pitchNextTime>eT
pitchEndtTime'interNum'=pitchTime'pitchNum'
endif
startPoint=pitchNum-1
endif
endfor
endfor
select PitchTier'newFileName$'
dianNum=pointNum
for interNum from 1 to intervalNum
if interNum=1
fileappend'saveFileName$'基频起点
fileappend'saveFileName$',
fileappend'saveFileName$'基频末点
fileappend'saveFileName$',
for dian from 1 to dianNum
fileappend'saveFileName$' 点
fileappend'saveFileName$''dian'
fileappend'saveFileName$'-基频值
fileappend'saveFileName$',
endfor
fileappend'saveFileName$''newline$'
endif
fileappend'saveFileName$''textGridFileName$'
fileappend'saveFileName$',
IN$=labeName'interNum$'
fileappend'saveFileName$''IN$'
fileappend'saveFileName$',
bT=beginTime'interNum'
fileappend'saveFileName$''bT'
fileappend'saveFileName$',
eT=endTime'interNum'
fileappend'saveFileName$''eT'
fileappend'saveFileName$',
sL=selLength'interNum'
fileappend'saveFileName$''sL'
fileappend'saveFileName$',
pST=pitchStartTime'interNum'
pET=pitchEndTime'interNum'
if pST>0 and pET>0
fileappend'saveFileName$''pST'
fileappend'saveFileName$',
fileappend'saveFileName$''pET'
fileappend'saveFileName$',
a=pST
b=pET
c=('b'-'a')/('dianNum'-1)
select PitchTier'newFileName$'
tempposition='tempposition'+'c'
endfor
endif
fileappend'saveFileName$''newline$'
endfor
endif
select TextGrid'newFileName$'
Remove
select PitchTier'newFileName$'
Remove
endfor
select Strings list
Remove
Exit
FFT分析频谱图导出的话可以参考这里
2.THD谐波总畸变率计算参考这里
3.谐波分量提取参考这里
4.谐波PLOT:HIT ME!!
基本指令格式:
power_fftscope
FFTDATA = power_fftscope(ScopeData)
FFTDATA = power_fftscope(FFTDATA)
power_fftscope(ScopeData)
power_fftscope(FFTDATA)例子:
假设要分析的信号是电流iL(在scope里命名为"iL1a")
先在powergui里分析一遍
然后在command窗口里输入:
>>FFTDATA = power_fftscope(iL1a) % FFTDATE是傅立叶分析相关参数的结构体
FFTDATA =
time: [120001x1 double]
signals: [1x1 struct]
blockName: 'apf6_PR/Scope13'
input: 1
signal: 1
startTime: 'last'
cycles: 1
fundamental: 60
maxFrequency: 1000
THDmaxFrequency: Inf
THDbase: 'fund'
mag: [17x1 double]
phase: [17x1 double]
freq: [17x1 double]
THD: 27.5218
samplingTime: 1.0000e-06
samplesPerCycle: 16667
DCcomponent: 0.0662
magFundamental: 8.9817
>>FFTDATE.fundamental=50 % 修改基频
FFTDATE =
fundamental: 50
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)