Zero values of a fitted curve
Afficher commentaires plus anciens
Hi to everybody, i have a time history dataset that i have fitted with a fourier series to find its peaks. Now i am in need of the zero crossing values of the curve, and as output the corresponding values of time of these zero crossing. Is there a function that does it automatically? I have tried with fnzeros but seems not to work for fitted curves but only for functions, am i wrong? Maybe i'm missing some statement in the code. Waiting for someone's reply i would thank in advance those willing to help me :D
5 commentaires
Star Strider
le 25 Sep 2015
‘...the zero crossing values of the curve...’
What curve? The original time series, the Fourier transform, or something else? How did you express the Fourier transform (for instance, amplitude, or separate real and imaginary components)?
ludovico
le 25 Sep 2015
Star Strider
le 25 Sep 2015
I still don’t understand what the ‘fitted curve’ is. If you have an objective function and a set of estimated parameters (such as those estimated by nlinfit or lsqcurvefit), you can use those parameters and the objective function to find the zero-crossings.
ludovico
le 25 Sep 2015
Star Strider
le 25 Sep 2015
Without actually seeing your data and the analysis you did, I cannot provide a definitive response.
Réponse acceptée
Plus de réponses (2)
fnzeros only appears to work with spline fits, which makes sense. That's the only way the zeros will have an analytical closed form solution. However, one option would be to sample your Fourier series fit at a finely spaced selection of points. Then, you can fit a spline to those points and use fnzeros on the spline fit to approximate the zeros of the Fourier fit.
If needed, you can refine further by using fzero() on the Fourier fit to do a numerical search. The result of fnzeros from above will give you a list of the initial seed points or search intervals that you would loop over, applying fzero() to each one.
ludovico
le 2 Oct 2015
3 commentaires
arich82
le 2 Oct 2015
It's still not entirely clear what you want:
Apparently, you have analytical expressions for SPOST, VEL, and ACC, and you want to find the zero crossing for, what exactly? (You also declared a t=[20:0.1:40], but never used it...)
I see the fitObject for C1, and another fitObject2 for SPOST. You could use the code from my previous post by defining a=[a0, a1] and b=[0, b1], and the result t would have to be extended periodically over n*2*pi to get the answer in the desired interval, and presumably, rescaled using w. (I don't have the appropriate toolbox, so I don't know the details of the fit function; the online documentation shows a p = 2*pi/(max(xdata)-min(xdata)), but not a w.)
However, for such a simple expression (i.e. a single sin & cos term), you can just compute the result analytically: assuming a0==0 (is this what you mean by "symmetric over the zero value"?), you can combine the sin and cos terms into a single sin (as you appear to have done), and solve for the time t when the entire argument becomes any integer multiple of pi.
For example, if your analytical expression is
y = 0 + a1*cos(w*t) + b1*sin(w*t)
let,
A = sqrt(a1^2 + b1^2);
phi = atan(a1/b1);
y == A*sin(w*t + phi)
then your roots would be
t = (pi*[-n:1:n] - phi)/w
for all integer n.
If you're still not clear, you'll have to explain exactly what it is you're having difficulty computing. (Also, it's better to post additional info in the comments, rather than posting it as a new answer...)
ludovico
le 5 Oct 2015
ludovico
le 5 Oct 2015
Catégories
En savoir plus sur Spline Postprocessing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

