Вы находитесь на странице: 1из 3

clear all;

clc;
load Murmurset;
f=input('please enter the date sequence :');
f2=int8(f);
fileheart='heart';
str1=date
str1datenum(date, 'dd-mmm-yyyy')
k=data(f) .Murmur;
frqsample=data(f) .fs;

fileheart= sprintf('%s_%i_%i_%i',fileheart,f2,str1)
fprintf('====================================================\n');
fprintf('Welcome to heard sound PCG Analysis\n');
fprintf('You have to requested data set number %i\n',f);
fprintf('Murmur lever is %i\n',k);
swtich k
case 2
frpintf('Murmur intensity:
case 3
fprintf('Murmur intensity:
case 4
fprintf('Murmur intensity:
case 5
fprintf('Murmur intensity:
le\n')
end

no Murmur \n')
week Murmur \n')
strong Murmur \n')
Murmur noted in Journal but not audib

fprintf('Frequency sampling from data structure :%i \n',freqsample);


fprintf('Creating wave file \n');
wavewrite (0.95*data(f) .data/max(abs(data(f) .data)),4000,fileheart);
fprintf('Created wave file %s \n',fileheart);
[y,fs,nbits] = wavread(fileheart);
reply=input('Play heart signal? [before filter] Y/N: ','s');
if reply == 'Y'
sound (y,fs,nbits)
end
fprintf ('frequency sampling from heart file : %i\n',fs);
maxfreq = max(y);
fprintf('Maximum intensity :%f5 \n',maxfreq);

n=length(y); %signal length in terms of sampling points !!!


time = (0:(N-1))'/fs; %Time increament for original signal
fameSoze = floor((256/fs)*fs);%frame size
overlap = floor(((256/fs)*fs)/2); %overlap of frame in sampling points
opt = 'nodelay';
z=[]; %array (strong)
for i=1:size(y,2) %i will repeat until 32000(signal length)
%====== Framming/segmenting the speach signal=======% to get quiasi stationary
%signal

x=y(:,i)l
[out,z,opt]=buffer[z;x],frameSize, overlap, opt);
%===== Windowing the speach signal=====%
windowed(:,i) = hamming(frameSize).*out(;,i);
end

figure('Name', 'Figure 1','Numbertitle','off');


subplot(3,1,1)
plot(out(:));
xlabel('Time (s)')l
ylabel('Amplitude');
grid on
axis tight
title('Block Framming');
subplot(3,1,2)
plot(windowed(1:end));
xlabel('Frame Size')l
ylabel('Amplitude');
grid on
axis tight
title('Windowing');
%==========Performing the Fast Fourier Transfor(FFT)==========%
[Pwr_spectrum,xf,freq]=heartFFT(y,fs);
subplot(3,1,3)
plot(frq,Pwr_specturm);
xlabel('Frequency (Hz)')l
ylabel('Power (dB)');
grid on
axis tight
title('PSD');
%applying butterworth highpass filter
fNorml=100/(fs/s);
[b, a]=butter(8,fNorml, 'high');
x1=filter(b,a,y);
reply1=input('Play Filtered Heart Signal? Y/N:
if reply1 == 'Y';
sound (x1,fs,nbits)
end

','s');

fNorm2=25/(fs/2);
[b,a] butter(8,fnorm2,'high');
x2=filter(b,a,y);
figure ('Name', 'Figure 2', 'Numbertitle', 'off');
subplot(3,1,1)
plote(time,y);grid on
xlabel('Time (s)');ylabel ('Amplitude');
titel(Orignal Signal');

subplot(3,1,2)
plote(time,xq);grid on
xlabel('Time (s)');ylabel ('Amplitude');
titel(Visualize Murmur');
subplot(3,1,3)
plote(time,x2);grid on
xlabel('Time (s)');ylabel ('Amplitude');
titel(Visualize sls2');

figure ('Name', 'Frequecny Response of Filter', 'Numbertitle', 'off');


freqz(b,a);
figure ('Name', 'Spectrogram', 'Numbertitle', 'off');
subplot(2,1,1)
specgram(y,256,fs);
title('Orignal spectrogram');
subplot(2,1,2)
specgram(xq,256,fs);
title('Filtered spectrogram');

Heart FFt Call Function


function [Pwr_specturm,xf,freq]=heartFFT(Signal, samplingFrequency)
N=length(signal); %length of signal in sampling points
t= (0:(N-1))/samplingFrequency; %Time increament t=N/fs
freq=(0:(N-1)/2)*(samplingFrequency/N); %frequency resolution k*fs/N
xf=fft(Signal);
xf=xf(1:lenght(freq));
Pwr_spectrum=(20*log10(abs(xf)));%.^2)/N %power of signal

Вам также может понравиться