Piece-wise Fourier series / Inverse Fourier series
Forward Fourier series:
For function call
[R,r0,T] = fspw(c,cK,T)
Input: (see theory)
c is standard form polynomial coefficient matrix for a piece-wise polynomial
cK is the highest degree, non-piece-wise coefficient
T is the total interval measure
Output: (see theory)
R is corresponding standard form frequency domain coefficient matrix
r0 is the DC coefficient
T is the total interval measure, preserved.
Given a piece-wise polynomial function in Heaviside form defined by a real-valued coefficient matrix c_{q,k} and measured interval 0<x<T:
p(x) = \sum_{q=0}^{Q-1}[u(x-qT/Q)-u(x-(q+1)T/Q] (\sum_{k=0}^{K-1}c_{q,k}x^k) + c_{K}x^K
Function outputs the Fourier coefficients using a complex basis defined by a real-valued coefficient matrix R_{k,q}
p(x) = \sum_{n=-\infty}^{+\infty}Q_{n}e^{2\pi i n x/T}
where
Q_{n} = \begin{cases} \sum_{k=0}^{K-1}[1/(2\pi i n)]^{k+1}(\sum_{q=0}^{Q-1}R_{k,q}e^{2\pi i n q/Q}), & n \neq 0 \\ r_{0}, & n=0 \end{cases}
Inverse Fourier series:
For function call
[c,cK,T] = ifspw(R,r0,T)
Input:
R is standard form frequency domain coefficient matrix for a piece-wise polynomial
r0 is the DC coefficient
T is the total interval measure, preserved.
Output:
c is corresponding standard form polynomial coefficient matrix
cK is the highest degree, non-piece-wise coefficients
T is the total interval measure, preserved
Function output is a piece-wise polynomial function in Heaviside form defined by a real-valued coefficient matrix c_{q,k} and measured interval 0<x<T:
p(x) = c_{q,K}x^{K} + \sum_{q=0}^{Q-1}[u(x-qT/Q)-u(x-(q+1)T/Q] (\sum_{k=0}^{K-1}c_{q,k}x^{k})
Function input is the Fourier coefficients using a complex basis defined by a real-valued coefficient matrix R_{k,q}
p(x) = \sum_{n=-\infty}^{+\infty}Q_{n}e^{2\pi i n x/T}
where
Q_{n} = \begin{cases} \sum_{k=0}^{K-1}[1/(2\pi i n)]^{k+1}(\sum_{q=0}^{Q-1}R_{k,q}e^{2\pi i n q/Q}), & n \neq 0 \\ r_{0}, & n=0 \end{cases}
Plotter function:
For function call
fspwplotter(R,r0,c,cK,T)
Example 1 Forward (Stair-step Wave Fourier Expansion):
c = [1;.8;.6;.4;.2;0];
cK=0;
T = 7;
[R,r0,T] = fspw(c,cK,T);
fspwplotter(R,r0,c,cK,T)
Example 2 Inverse
R = [1 3 10 1 -4 -10; -10 4 2 5 5 5 ; -20 100 10 -10 -1 -4 ; 10 -4 -20 -30 2 3]
r0 = 0;
T = 7;
[c,cK,T] = ifspw(R,r0,T);
fspwplotter(R,r0,c,cK,T)
Cite As
Ryan Black (2024). Piece-wise Fourier series / Inverse Fourier series (https://www.mathworks.com/matlabcentral/fileexchange/79415-piece-wise-fourier-series-inverse-fourier-series), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
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.12 | ok hopefully final update for a while |
||
1.0.11 | keep adding comments and making the notation consistent between all the sub-functions. |
||
1.0.10 | i think i may have forgot to update last time |
||
1.0.9 | for Quora |
||
1.0.8 | split cK from coefficient matrix as a 2nd case condition |
||
1.0.7 | added to descriptiion |
||
1.0.6 | accidentally displayed an output matrix I was trying to hide. |
||
1.0.5 | Added inverse Fourier series function and plotter function to same File exchange contribution. |
||
1.0.4 | Added transform, inverse transform and plotter function all to same File exchange contribution. |
||
1.0.3 | description edit |
||
1.0.2 | description edit |
||
1.0.1 | Updated description. |
||
1.0.0 |