help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smoothing a roughly sinusoidal signal


From: llrjt100
Subject: Re: Smoothing a roughly sinusoidal signal
Date: Fri, 8 Nov 2019 05:58:06 -0600 (CST)

Thanks for your suggestion - I'd like to give this a try. 

I'm very new to signal processing - how do I go about finding parameters a &
b? 

I've adapted an example I found on the web, but not really sure what I'm
doing...

data = csvread('sidvel.csv');

t = data(:,1);
a = data(:,2);
s = data(:,3);
d = data(:,4);
plot(t,a,t,s,t,d);

%plot(abs(fft(a)));

%function with parameters
%fun = @(t,p) p(1)*sin(p(2)*t+p(3)) + p(4);  % sine wave with 4 parameters
to estimate
fun = @(t,p) p(1)*sin(p(2)*t) + p(3)*cos(p(2)*t); %a*sin(kt) + b*cos(kt)
fcn = @(p) sum((fun(t,p)-a).^2);  %Cost function to minimize the sum of the
squares

%Initial guess for parameters
p0 = [4 0 0 0];

%Parameter optimization
par = fminsearch(fcn, p0);

%See if estimated parameters match measured data
yest = fun(t, par)
plot(t,a,t,yest)




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]