Finding Fourier Transform of tri(\frac{t}{2\pi })Cos(2\pi (\frac{5}{\pi })t)

Click For Summary
SUMMARY

The discussion focuses on finding the Fourier Transform of the function tri(t/(2π))Cos(2π(5/π)t) using MATLAB. The user initially encountered matrix dimension errors while attempting to compute the function but resolved the issue by using element-wise multiplication with the '.*' operator. The final solution involves breaking the triangular function into two components and utilizing rectangular functions to represent each segment, allowing for successful plotting of the combined function.

PREREQUISITES
  • Understanding of Fourier Transform concepts
  • Familiarity with MATLAB programming
  • Knowledge of element-wise operations in MATLAB
  • Basic understanding of piecewise functions and their graphical representation
NEXT STEPS
  • Learn about MATLAB's 'fft' function for computing Fourier Transforms
  • Explore the use of rectangular functions in signal processing
  • Study MATLAB's plotting functions for visualizing mathematical functions
  • Investigate the properties of triangular and rectangular functions in Fourier analysis
USEFUL FOR

Students and professionals in signal processing, MATLAB users, and anyone interested in Fourier analysis and graphical representation of mathematical functions.

frenzal_dude
Messages
76
Reaction score
0
I want to input the following function so I can find the Fourier Transform of it:

tri(\frac{t}{2\pi })Cos(2\pi (\frac{5}{\pi })t)

I couldn't find a simple way of doing a tri function so this is what I inputted in matlab:

a(t_{1}) = (\frac{t_{1}}{\pi }+1)Cos(2\pi (\frac{5}{\pi })t_{1}) where -π < t1 < 0

b(t_{2}) = (-\frac{t_{2}}{\pi }+1)Cos(2\pi (\frac{5}{\pi })t_{2}) where 0 < t2 < π

g(t) = a(t_{1}) + b(t_{2})

Here is what I typed into matlab:
>> t1 = -pi:0.01:0;
>> t2 = 0:0.01:pi;
>> g = ((t1/pi) + 1)*cos(2*pi*(5/pi)*t1) + ((-t2/pi) + 1)*cos(2*pi*(5/pi)*t2);

But I get this error:
? Error using ==> mtimes
Inner matrix dimensions must agree.

I looked in the workspace and t1 and t2 both have the same dimensions of 1x315 (just different min anad max values).

Thanks for your help.
 
Engineering news on Phys.org
OK I managed to get this to work:

g=((t1/pi) + 1).*cos(2*pi*(5/pi)*t1) + ((-t2/pi) + 1).*cos(2*pi*(5/pi)*t2);

But how can I plot this? I tried creating a new time vector t=-pi:0.001:pi;

But then I get this error:
? Error using ==> plot
Vectors must be the same lengths.
 
OK worked it out! :)

To do a tri function multipled with another function, you need to break it up into two components and think of the tri as two straight lines, and then use a rect function for each of the two components, as shown below:

t = -pi:0.1:pi;
y1 = ( (-pi <= t) .* (t < 0 ) ); %rect[(t-pi/2)/pi]
g1 = y1.*((t/pi)+1).*cos(2*pi*(5/pi)*t);
y2 = ( (0 <= t) .* (t < pi ) ); %rect[(t+pi/2)/pi]
g2 = y2.*((-t/pi)+1).*cos(2*pi*(5/pi)*t);
plot(t,g1+g2);
 
Last edited:

Similar threads

Replies
5
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
978
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K