Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all;
- clf;
- fs = 3;
- Ts = 1/fs;
- num_sec = 6;
- ws = 2*pi*fs;
- wc = ws/2;
- t = linspace(-floor(num_sec/2), floor(num_sec/2), num_sec*100+1);
- x = exp(-2*t.^2).*cos((2*pi).*t);
- h = Ts*wc/pi*sinc(wc.*t/pi);
- xp = zeros(1, num_sec*fs);
- tp = zeros(1, num_sec*fs);
- index = 1;
- dec = 0;
- for iter = 1:length(t)
- if(t(iter) < 0)
- dec = t(iter) - ceil(t(iter));
- else
- dec = t(iter) - floor(t(iter));
- end
- for k = -floor(num_sec/2):floor(num_sec/2)
- if(round(dec, 2) == round(k*Ts, 2))
- for n = 1:fs
- xp(index) = x(iter);
- tp(index) = t(iter);
- index = index + 1;
- end
- end
- end
- end
- xr = zeros(1, length(xp));
- for iter = 1:length(tp)
- for n2 = -10000:10000
- xr(iter) = xr(iter) + xp(iter)*Ts*wc/pi*...
- sinc(wc*(t(iter)-n2*Ts)/pi);
- end
- end
- figure(1);
- plot(t, x, 'b'); hold on
- plot(tp, xr, 'r')
- plot(tp, xp, 'or');
- xlabel('time (s)');
- axis([-floor(num_sec/2) floor(num_sec/2) -1.2 1.2]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement