Comparing a signal reconstruction with given equation
1 view (last 30 days)
Show older comments
I am supposed to compare a signal reconstruction with the given equation g_t = sum(n = 1:20) of g_a*(n/2B)sinc(2piBt-npi) . I am given the values for g_t but mine don't match, can anyone see why? first couple should be 0, 0.016, 0.037...etc
clear; clc
t = 0:0.005:1;
g_t = 0;
g_a = sin(2*pi*t)+(0.5*cos(6*pi*t))+(0.25*cos(18*pi*t));
e_t = 0;
B = 10;
prod1 = 0;
prod7 = 0;
%------------------------------Equation----------------------------------
for n = 1:20
g_t = g_t+(n/20).*g_a.*((sin((2*pi*B*t)-(n*pi)))./((2*pi*B*t)-(n*pi)));
end
e_t = g_a - g_t;
%----------------------------------Plots----------------------------------
figure(1);
hold on;
box on;
plot(t,g_t,'r');
plot(t,g_a,'b');
plot(t,e_t,'y');
ylabel('amplitude g(t)');
xlabel('time t');
title('sync waveform reconstruction');
axis([0 1 -2 2]);
fileID = fopen('Signal Reconstruction.txt', 'w');
fprintf(fileID, '%34s\n','Signal Reconstruction');
fprintf(fileID, '%38s\n','Using Sinc Waveform');
fprintf(fileID, '%2s %8s %7s %9s %7s\n','i','prod1','prod7',...
'gr(t)','delta');
for i = 1:99
fprintf(fileID,'%2.0f %+8.3f %+8.3f %+8.3f %+8.3f\n',i,...
prod1,prod7,g_t(i),e_t(i));
end
0 Comments
Answers (1)
Arnab Sen
on 23 Feb 2016
Hi James ,
I observe some inconsistency in the definition of 'g_t' and compute of 'g_t' in the code.
I think as per the definition 'g_t' should be as follows:
for n = 1:20
g_t = g_t+(n/2*B).*g_a.*(sinc((2*pi*B*t)));
end
0 Comments
See Also
Categories
Find more on Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!