Fit Underdamped oscillator to data
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have been trying to fit a under-damped oscillator equation to some data that I have. I have tried most of the online examples I can find with little success. My data can be visualized below and I have attached a file with the raw data as well.
0 Commenti
Risposte (1)
Star Strider
il 2 Dic 2015
This is not perfect but the best I can do:
D = load('matheu Broom rate0.2.mat');
t = D.t;
x = D.x;
[xu,ixu] = max(x);
[xl,ixl] = min(x);
xr = (xu-xl); % Range of ‘x’
xm = mean(x); % Estimate d-c offset
xz = x - xm; % Subtract d-c Offset
zt = t(xz .* circshift(xz,[-1 0]) <= 0); % Find zero-crossings
per = 2*mean(diff(zt)); % Estimate period
objfcn = @(b,x) b(1).*exp(b(2).*x).*(sin(2*pi*x./b(3) + 2*pi/b(4))) + b(5); % Function to fit
ssecf = @(b) sum((objfcn(b,t) - x).^2); % Sum-Of-Squares cost function
init_est = [xr; -0.01; per; t(ixl)/per; xm]; % Initial Parameter Estimates
[s,sse] = fminsearch(ssecf, init_est) % Minimise Sum-Of-Squares
tp = linspace(min(t),max(t), 250);
figure(1)
plot(t,x,'b', tp,objfcn(s,tp), 'r')
grid
axis([xlim 0.3 0.7])
text(0.006, 0.62, sprintf('x(t) = %.3f\\cdote^{%.3f\\cdott}\\cdotsin(2\\pit\\cdot%.3f + %.3f) + %.3f', s(1:2), 1/s(3), 2*pi/s(4), s(5)))
2 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!