MATLAB Truncated Fourier series analysis in Matlab

Click For Summary
The discussion centers on creating a MATLAB function to reconstruct a signal from a set of Fourier series coefficients. The function should take three inputs: a finite set of coefficients, the fundamental period T, and a time vector t. The expected output is a vector x that matches the length of t, containing reconstructed signal values. A provided code snippet initializes a zero vector and attempts to calculate the Fourier series using a loop. However, there is a concern regarding the use of 'i' as the imaginary unit and 'pi' for the mathematical constant, which may not be recognized in all programming languages. This highlights the importance of ensuring that the code is compatible with MATLAB's syntax and conventions for complex numbers and mathematical constants.
d2009
Messages
1
Reaction score
0
a) Write a Matlab function, which accepts the following inputs

-a finite set of Fourier series coefficients

-the fundamental period T of the signal to be reconstructed

-a vector t representing the times for which the signal will be reconstructed.

This function should produce an output x[t][/n]( should be a vector x with length equal to the length of t containing values of xn at the times indicated by t.

this is the code i have come up with so far.

function fourier1=f(a,T,t)
fourier1=zeros(length(a),1);
for n=1:length(a)
fourier1(n)=(a(n)*exp((i*(2*pi/T)*n*t)));
end;
 
Last edited:
Physics news on Phys.org
What language is that? Unless the language recognizes i as the imaginary operator, and "pi" as 3.14159, it won't work.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K