Info

This question is closed. Reopen it to edit or answer.

Using fourier to approximate system output. Approximation and exact plots dont agree.

1 view (last 30 days)
Hello, I am trying to write a program that will allow me to find the exact output function for a system given the input function and the impulse response in the time domain. I want to use convolution to find the exact answer, and use the fourier transform on my input and impulse response to approximate the solution as well. However, when I plot my inverse fourier transform of my frequency domain ouput I get a significantly different plot than my approximation shows. Can anyone tell me where I am going wrong.
clf;
clear all;
t = -5:0.001:5;
w = -50:0.1:50;
%x = exp(-3*t).*heaviside(t);
%h = exp(-2*t).*heaviside(t);
x = zeros(size(t));
h = zeros(size(t));
for iter = 1:length(t)
x(iter) = t(iter)^2*exp(-t(iter)^2)*cos(t(iter)^2)^2;
h(iter) = exp(0.2*t(iter)^2)*sin(t(iter)^2)*heaviside(t(iter));
end
X = zeros(size(w));
H = zeros(size(w));
for iter = 1:length(w)
X(iter) = trapz(t,x.*exp(-1j*w(iter)*t)); %Fourier Transform
H(iter) = trapz(t,h.*exp(-1j*w(iter)*t));
end
Y = X.*H;
y = zeros(size(t));
for iter = 1:length(t)
y(iter) = trapz(w, Y.*exp(1j*w*t(iter)))/(2*pi);
end
syms t0 w0;
%x_exact = exp(-3*t0)*heaviside(t0);
%h_exact = exp(-2*t0)*heaviside(t0);
%X_exact = fourier(x_exact, t0);
%H_exact = fourier(h_exact, t0);
%Y_exact = H_exact*X_exact;
x_exact = x;
h_exact = h;
y_exact = conv2(h_exact, x_exact, 'same');
figure(1);
plot(t, y_exact, t, abs(y));
legend('Exact', 'Approximate');
title('Exact and approximate transform');
axis([-5 5 -.02 5]);

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!