Pre-define some weights/phase using the fit function to fit a fourier series to data

4 views (last 30 days)
I am trying to decompose some data into a Fourier Series using the fit function, such that:
f = fit(x,y,'fourier4')
I would like to be able to pre-define some of the outputs for this fit (i.e. set odd fourier coefficients to zero and pre-define a phase term) and then have the function invert for the remaining undefined components. Is this possible? And if it cant be done using the fit function does anyone know of another way to do it?
The problem I am working on involves decomposing azimuthally varying pre-stack seismic data into a fourier series where azimuth is the main variable, however incident angle is a secondary variable and at any given location in space I want the fourier weights to be a function of incident angle but the phase term to be constant at all incident angles. My initial thought was to fit the data at all incident angles simultaneously to get the (constant) phase term, and then to re-fit the data at each incident angle separately while forcing the phase term to be constant to find the weights that vary with incident angle.
UPDATE: I have been playing around with making a custom non-linear fitting function using the 'fittype' function to attempt to make a fit specific to my needs. I havent gotten it quite right yet but feel I am on the right path. Any suggestions would be appreciated.

Accepted Answer

Anthony Barone
Anthony Barone on 13 Mar 2015
I was able to figure this one out on my own. I created my own custom fitting function using the following code:
w=1;
Fourier4_mod=fittype( @(a0,a2,b2,a4,b4,x) a0 + a2*cos(2*x*w) + b2*sin(2*x*w) + a4*cos(4*x*w) + b4*sin(4*x*w));

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!