fs(x,T0,n,type)
%% 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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Function is improved.
|