fs(x,T0,n,type)

This function is written to calculate the cofficients of fourier series.

You are now following this Submission

%% This function is written to calculate the cofficients of fourier series.
%% in the function arguments, fs(x,T0,n,type), note that :
%% x : the fuction that you might to calculate it's fourier series,
%% note that you should enter one period of the periodic function(x).
%% Be careful! You should enter one period of signal in range [-T/2,T/2]
%% ,not [0 T] or other ranges.
%% T0 : Period of function.
%% n : Number of cofficients must be calculated.
%% type : type 0 to calculate the magnitude and phase of cofficients.
%% type 1 to calculate the real and imaginary part of cofficients.
%% Examples :
%% (This code is written in MATLAB ver. 2016a)
%% clc
%% clear
%% close all
%% syms t
%% Example 1 : Fourier Series of even triangle wave
%% x1 = (t+1)*heaviside(t+1) -(t)*heaviside(t)-heaviside(t);
%% x2 = -(t-1)*heaviside(-(t-1)) +(t)*heaviside(-t)-heaviside(-t);
%% x = x1 + x2;
%% fs(x,2,5,0)
%% Example 2 : Fourier Series of odd rectangle wave
%% x1 = 2*heaviside(-(t+2))-2 + 2*heaviside(t);
%% x2 = 2*heaviside(t) -2*heaviside(t-2);
%% x = x1 + x2;
%% fs(x,4,5,0)

Cite As

davood shaghaghi (2026). fs(x,T0,n,type) (https://www.mathworks.com/matlabcentral/fileexchange/41684-fs-x-t0-n-type), MATLAB Central File Exchange. Retrieved .

Categories

Find more on Fourier Analysis and Filtering in Help Center and MATLAB Answers

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0

Function is improved.
2 examples are added.