how can i find zero crossing irregularity of the sound data?
조회 수: 4 (최근 30일)
이전 댓글 표시
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/555717/image.png)
I have an sound file of an asthma patient. My aim here is to find the zero crossing irregularity of this sound file. Can you help me?
댓글 수: 0
답변 (1개)
Star Strider
2021년 3월 19일
Find the zero-crossings using something like this approach:
[y,Fs] = audioread('Asthma.wav'); % Import Sound File (Use The Correct File Name)
zxi = find(diff(sign(y(:,1)))); % Approximate Indices Of Zero-Crossinga
ylen = numel(y(:,1));
tv = linspace(0, ylen, ylen).'/Fs; % Time Vector (Column Vector)
for k = 1:numel(zxi)
idxrng = max(1,zxi(k)-2):min(ylen,zxi(k)+2); % Index Range
B = [t(idxrng) ones(size(idxrng))] \ y(idxrng); % Parameters
txz(k) = B(2)/B(1); % Interpolated Precise Time Of Zero-Crossing
end
However, if you are doing time-frequency analysis of the wheezes, the Signal Processing Toolbox pspectrum function with the 'spectrogram' option is likely most appropriate. (The spectrogram function may also be useful, however the outputs are not as straightforward to interpret.)
댓글 수: 6
Star Strider
2021년 3월 20일
I would have to have the structure array to experiment with to advise you on that.
Star Strider
2021년 3월 20일
I would do something like this to do the time-frequency analysis:
W = load('sampleWheezeData.mat');
% LungSounds = W.structWheeze;
% SoundData = LungSounds.SoundData;
% Properties = LungSounds.Properties;
C1 = struct2cell(W.structWheeze);
Fs = 44100; % Not Provided, Wild Guess
for k = 1:size(C1,2)
figure(k)
pspectrum(C1{2,k}, Fs, 'spectrogram')
end
See the documentation on pspectrum for details on how to extract necessary information from it. I am not sure what sort of analysis you want to do with these data, however this should get you started.
This routine will extract the zero-crossing data:
for k1 = 1:size(C1,2)
y = C1{2,k1};
zxi = find(diff(sign(y(:,1)))); % Approximate Indices Of Zero-Crossinga
ylen = numel(y(:,1));
tv = linspace(0, ylen, ylen).'/Fs; % Time Vector (Column Vector)
for k2 = 1:numel(zxi)
idxrng = max(1,zxi(k)-2):min(ylen,zxi(k)+2); % Index Range
B = [tv(idxrng) ones(size(idxrng)).'] \ y(idxrng); % Parameters
txz(k1,k2) = -B(2)/B(1); % Interpolated Precise Time Of Zero-Crossing
end
end
figure
contourf(txz)
set(gca, 'YTick',1:5)
however I did not find the result to be very informative when I plotted it.
참고 항목
카테고리
Help Center 및 File Exchange에서 AI for Signals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!