fs(x,T0,n,type)

This function is written to calculate the cofficients of fourier series.
338 Downloads
Updated 24 Sep 2016

View License

%% 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 (2024). fs(x,T0,n,type) (https://www.mathworks.com/matlabcentral/fileexchange/41684-fs-x-t0-n-type), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Fourier Analysis and Filtering in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

Function is improved.
2 examples are added.