# Find the non null complex Fourier coefficients

I'm doing my homework on signal processing in MatLab and I'm stuck on an exercise.

I'm given this signal $x(t)=1 + 2\sin(12\pi t+\frac{\pi}{4})\cos(21\pi t);$ and I have to get the non null complex Fourier coefficients using this expression $$C_{m}=\frac{1}{T_{0}}\int_{-\frac{T_{0}}{2}}^{\frac{T_{0}}{2}}x(t)e^{-im\omega_{0}t}dt$$

Analytically I've found that $\omega_{0} = 2 rad/s$ so $C_{m} = {2,4}$ and $\Theta_{m} = -\pi,\frac{\pi}{3},\frac{\pi}{4}$

Now I have to do this in MatLab. I've created the following script where I'm calculating the integral but now I'm stuck and don't know what to do next. Can you point me in some direction?

This is my script:

function cfc
syms m t;
% Signal
x1 = 1 + 2*sin(12*pi*t+pi/4)*cos(21*pi*t);

%T0 and w0
T01 = 2*pi/3;
w01 = 2*pi/T01;

% Cm
disp('Cm');
Cm1 = 1/T01 * int(x1*exp(-1i*m*w01*t),t,-T01/2,T01/2);
pretty(Cm1);
end

-

Look, it's not clear to me what you are doing analytically. It looks like the problem is asking you to find the values of $m$ for which the Fourier coefficients are nonzero. These correspond to the frequency components of your signal. To see these, you have to use the product relation

$$2 \cos(a) \sin(b) = \sin{(a+b)} - \sin{(a-b)}$$

and then note that $\sin{(x+\pi/4)} = \sqrt{2} (\cos{x} + \sin{x})$. Once you unwrap your signal like this, then you'll immediately have the nonzero Fourier coefficients.

-
Hi Ron. Thanks. I've unrapped my signal to cos(0t+0)+cos(33πt-π/4)+cos(9πt+π/4). From here I can see that the Cm's are 1. I'm having trouble is to get to the same resoult using the MatLab script – Favolas Mar 25 '13 at 14:15
Well, not quite. You have nonzero components at $m=0, \pm 9, \pm 33$, and the amplitudes of the nonzero frequencies are $e^{\pm i \pi/4}$. (You are using a complex representation of the FS.) As for your Matlab script, I do not understand this angular frequency you are using - it removes the orthogonality from the series and will stymie your ability to find the nonzero frequencies. – Ron Gordon Mar 25 '13 at 14:22
Thanks Rob. Should $\Omega_{0}$ be 3 since its the gcd between 0,9 and 33? – Favolas Mar 25 '13 at 14:25
No, it should just be $1$. In fact, it should just not be. – Ron Gordon Mar 25 '13 at 14:27
Sorry but had a problem and cant come here soon. Thanks for your help but I don't understand – Favolas Mar 25 '13 at 22:15