### Highlights from fs(x,T0,n,type)

Join the 15-year community celebration.

Play games and win prizes!

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 4.18 KB File ID: #41684 Version: 1.0

# fs(x,T0,n,type)

### davood shaghaghi (view profile)

08 May 2013 (Updated )

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

File Information
Description

%% 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)

MATLAB release MATLAB 9.0 (R2016a)
MATLAB Search Path
`/`