suru
Full Member level 3
sublotting frequncy plot reading values from excel file
i want to plot time and frequency plots reading from excel file.
the following lines are helpful for reading from excel file and selecting perticular column also.
time = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%num;
inp = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%inp;
outp= xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%outp;
i have got correct time plot but not getting correct frequncy plot. i got frequncy plot also but shows wrong values. program is written below.
plz help me.
complete program:
%reading excel column and plotting time and frequncy domain
%analysis- feb 2008.
clc
time = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%num;
inp = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%inp;
outp= xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%outp;
subplot(2,2,1);
plot(time,inp);
grid on;
title(' input plot ');
xlabel('time----->');
ylabel('amp in volts----->');
%........................................
subplot(2,2,2);
plot(time,outp);grid on;
title(' output plot ');
xlabel('time----->');
ylabel('amp in volts----->');
subplot(2,2,3);
plot(inp( 200:6000),outp(200:6000));grid on;
title(' input vs output plot ');
xlabel('input----->');
ylabel('output----->');
%................fft sec...........
%...............................
Fs=-10000;
n=(1:100);
f1=outp/Fs; % digital freqency is the sampled frequency
x1=f1;%cos(2*pi*f1*n);
% number of samples for the FFT
N=512;
% we calculate just the magnitude (abs), not the phase
k=abs(fft(x1,N));
% now shift the spectrum to be centered
l=fftshift(k);
% X2=fftshift(X2);
% X3=fftshift(X3);
% digital frequency range will be from -1/2 to 1/2, so
% there is a need to unnormalize it to our sampling
% frequency, which is Fs.
% this means our freq range will go from -Fs/2 to Fs/2
f=Fs.*[-N/1:N/1-1]/N;
grid on;
title(' Frequency domain analysis ');
xlabel('frequency (Hz)----->');
ylabel('gain in db----->');
% .............end..............................
i want to plot time and frequency plots reading from excel file.
the following lines are helpful for reading from excel file and selecting perticular column also.
time = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%num;
inp = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%inp;
outp= xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%outp;
i have got correct time plot but not getting correct frequncy plot. i got frequncy plot also but shows wrong values. program is written below.
plz help me.
complete program:
%reading excel column and plotting time and frequncy domain
%analysis- feb 2008.
clc
time = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%num;
inp = xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%inp;
outp= xlsread('D:\INSTALLED\MATLAB\work\tone.xls',-1);
%outp;
subplot(2,2,1);
plot(time,inp);
grid on;
title(' input plot ');
xlabel('time----->');
ylabel('amp in volts----->');
%........................................
subplot(2,2,2);
plot(time,outp);grid on;
title(' output plot ');
xlabel('time----->');
ylabel('amp in volts----->');
subplot(2,2,3);
plot(inp( 200:6000),outp(200:6000));grid on;
title(' input vs output plot ');
xlabel('input----->');
ylabel('output----->');
%................fft sec...........
%...............................
Fs=-10000;
n=(1:100);
f1=outp/Fs; % digital freqency is the sampled frequency
x1=f1;%cos(2*pi*f1*n);
% number of samples for the FFT
N=512;
% we calculate just the magnitude (abs), not the phase
k=abs(fft(x1,N));
% now shift the spectrum to be centered
l=fftshift(k);
% X2=fftshift(X2);
% X3=fftshift(X3);
% digital frequency range will be from -1/2 to 1/2, so
% there is a need to unnormalize it to our sampling
% frequency, which is Fs.
% this means our freq range will go from -Fs/2 to Fs/2
f=Fs.*[-N/1:N/1-1]/N;
grid on;
title(' Frequency domain analysis ');
xlabel('frequency (Hz)----->');
ylabel('gain in db----->');
% .............end..............................