I have a data of several thousands samples (say 60000), the sampling frequency is given (1 MHz). I want to divide the data in equal frames, each of 500 samples that makes 120 frames, then plot all those (120) frames on the same graph to compare them. I want to plot in time domain and frequency domain. I have been able to do the time domain plot but I don’t know how to do the frequency domain plot of all of the signals in the same graph. Looking forward for the help. Thanks
You put all of the signals you want in a matrix (each column is a different partition of the signal);
data = rand(60000,1); % replace with your data y = ; for i = 1:120 y(:,i) = data((i-1)*500+1:(i)*500);; end
% perform the fft as; L = 500; Y = fft(y); P2 = abs(Y/L); P1 = P2(1:L/2+1,:); P1(2:end-1,:) = 2*P1(2:end-1,:);
% obtain frequency matrix; Fs = 1e3; % sampling frequency f = Fs*(0:(L/2))/L;
% plot frequency domain figure(1) semilogy(f,P1) % plot time domain figure(2) plot([1:L]/Fs,y)
Make sure you understand what is done in each step and if you have questions, feel free to ask.
y =  just makes y an empty matrix. It is not a necessary code. I include it in the off chance that you had a variable named y in your code. That line would delete any contents of previously assigned y variable values