MAP_Gait_Dynamics/SpectralAnalysisGaitfunc.m

19 lines
1.2 KiB
Mathematica
Raw Permalink Normal View History

2020-11-07 16:46:05 +01:00
function [ResultStruct] = SpectralAnalysisGaitfunc(dataAccCut_filt,WindowLen,FS,N_Harm,LowFrequentPowerThresholds,AccVectorLen,ResultStruct)
P=zeros(0,size(dataAccCut_filt,2));
2021-07-03 16:26:55 +02:00
for i=1:size(dataAccCut_filt,2) % pwelch = Welchs power spectral density estimate
2020-11-07 16:46:05 +01:00
[P1,~] = pwelch(dataAccCut_filt(:,i),hamming(WindowLen),[],WindowLen,FS);
2021-07-03 16:26:55 +02:00
[P2,F] = pwelch(dataAccCut_filt(end:-1:1,i),hamming(WindowLen),[],WindowLen,FS); % data
2020-11-07 16:46:05 +01:00
P(1:numel(P1),i) = (P1+P2)/2;
end
2021-07-03 16:26:55 +02:00
dF = F(2)-F(1); % frequencies
2020-11-07 16:46:05 +01:00
% Calculate stride frequency and peak widths
[StrideFrequency, ~, PeakWidth, MeanNormalizedPeakWidth] = StrideFrequencyRispen(P,F);
[ResultStruct] = HarmonicityFrequency(dataAccCut_filt, P,F, StrideFrequency,dF,LowFrequentPowerThresholds,N_Harm,FS,AccVectorLen,ResultStruct);
2021-07-03 16:26:55 +02:00
ResultStruct.IH_VT = IndexOfHarmonicity(dataAccCut_filt(:,1),(5*StrideFrequency),10); % expect fmax at step frequency (2* stridefrequency), what happens if you increase fmax (~ PSD)
ResultStruct.IH_ML = IndexOfHarmonicity(dataAccCut_filt(:,2),(5*StrideFrequency),10); % expect fmax at stride frequency
ResultStruct.IH_AP = IndexOfHarmonicity(dataAccCut_filt(:,3),(5*StrideFrequency),10); % expect fmax at step frequency (2* stridefrequency)
2020-11-07 16:46:05 +01:00
end