MATLAB: How to integrate this equation

integrationplot

Hello, I have a problem trying to integrate. I have only been using MatLab for about 3 months now, very new to it.
This is the equation I am trying to integrate x(t) = (-0.75)^t *(u(t) – u(t-8)) I had to use the freqz function first, and now it's asking me to compare freqz to manually doing the Fourier Transform, which basically states taking the integral from negative infinity to positive infinity of x(t) * e^(-2pi*f*t) dt
I am kinda skipping a step and integrating from 0 to 8, it's 0 everywhere else (however if possible I'd like to know how to integrate from negative infinity to positive infinity). Anyways, that's basically what I'm trying to do, integrate, (-0.75)^t from 0 to 8. This is what I have currently but I keep getting errors. Should I be using 'integral' or 'int'?
clear all; close all;
t = [0:.01:10];
j = sqrt(-1);
syms f;
u1 = heaviside(t);
u2 = heaviside(t - 8);
x = ((-0.75).^t).*(u1 - u2);
y = ((-0.75).^t) .* exp(-2*pi.*j.*t.*f);
X = int(y, 0, 8);
plot(X);

Best Answer

If your function is defined over ‘t’ from 0 to 8, integrate over that time. I’m not quite certain what you’re doing, so you’ll likely have to change this code to fit, but some revision of it should work:
syms f t
u1 = heaviside(t);
u2 = heaviside(t - 8);
x = ((-0.75).^t).*(u1 - u2);
y = x .* exp(-2*pi.*1i.*t.*f);
X = int(y, t, 0, 8);
X = rewrite(X, 'sincos');
X = simplify(X, 'steps',10)
figure(1)
ezplot(abs(X), [0 2*pi])
Related Question