MATLAB MATLAB - Fourier (how do I do this)

  • Thread starter Thread starter FrogPad
  • Start date Start date
  • Tags Tags
    Fourier Matlab
AI Thread Summary
To find the Fourier transform of cos(ω₀t) in MATLAB, the user seeks a method to obtain a general solution that includes a variable 'a'. The initial attempt using the command `fourier(cos(t))` yields the specific result for ω₀ = 1, which is π*(dirac(w - 1) + dirac(w + 1)). To achieve a more general result, the user can define 'a' as a symbolic variable before performing the Fourier transform. By initializing 'a' with `syms a t` and then using `fourier(cos(a*t))`, MATLAB returns the desired output of π*(dirac(w - a) + dirac(w + a), allowing for verification of more complex transforms.
FrogPad
Messages
801
Reaction score
0
I would like to use Matlab to check my answers.

For example, I want to find the Fourier transform of \cos \omega_0 t.

I know the answer is:
\pi ( \delta(\omega - \omega_0) + \delta(\omega + \omega_0)).

How do I do this in Matlab. All I can find is something like this:
Code:
clc;
syms t;
fourier(cos(t))

This returns:
Code:
pi*(dirac(w-1)+dirac(w+1))

I would really like to be able to do something like:
Code:
clc;
syms t;
fourier(cos(a*t))

and get:
Code:
pi*(dirac(w-a)+dirac(w+a))

so I can actually check harder transforms.

How would I do this?

Thanks in advance :)
 
Physics news on Phys.org
Just make sure that "a" is also initialized in your symbolic variables.

>> syms a t
>> fourier(cos(t))

ans =

pi*(dirac(w - 1) + dirac(w + 1))

>> fourier(cos(a*t))

ans =

pi*(dirac(a + w) + dirac(a - w))
 
Back
Top