· 4 years ago · Jun 13, 2021, 02:00 PM
1% Enter your MATLAB code below
2readChannelID = ; %%your channel ID here
3readAPIKey = ' '; %%your read API key here
4y1 = thingSpeakRead(readChannelID,'Field',1,'NumPoints',500,'ReadKey',readAPIKey);
5fs = 250 % find the sampling rate or frequency
6T = 1/fs;% sampling rate or frequency
7window = 120; % 2 min 0r 120 second
8N = 500;
9t = (0 : N-1) / fs;% sampling period
10
11%Compute the spectrum of the ECG and provide remarks on the spectral features of the ECG
12%DFT to describe the signal in the frequency
13NFFT = 2 ^ nextpow2(N);
14Y = fft(y1, NFFT) / N;
15f = (fs / 2 * linspace(0, 1, NFFT / 2+1))'; % Vector containing frequencies in Hz
16amp = ( 2 * abs(Y(1: NFFT / 2+1))); % Vector containing corresponding amplitudes
17figure;
18plot (f, amp);
19title ('plot Frequency Response of ECG signal');
20xlabel ('frequency (Hz)');
21ylabel ('|y(f)|');
22grid on;