How to Curvefit amplitude output of a spring-mass-damper system to find coefficients?
8 views (last 30 days)
Show older comments
First of all, I'm not sure if the title gives the right idea, and if this is possible. If that's the case, my apologies in advance.
I have a data set that displays the amplitude of a system that shows decaying motion. (Sample data set attached). I want to identify the quadratic damping applied in the system. So, I want to find a polynomial in the form a + b*(amplitude). I don't want a polynomial of nth order either. How can I do this?
0 Comments
Accepted Answer
Star Strider
on 7 Mar 2024
Try this —
load('sampleData.mat')
% whos
objfcn = @(b,t) b(1) .* exp(b(2).*t) .* cos(2*pi*b(3)*t + b(4)) + b(5);
Lvlm = islocalmax(y, 'MinProminence',0.5);
Per = mean(diff(x(Lvlm)));
Freq = Per;
ymax = max(y);
B0 = [ymax; -1E-2; Freq; randn(2,1)];
[B,fv] = fminsearch(@(b) norm(y - objfcn(b,x)), B0)
% nnz(Lvlm)
figure
plot(x,y)
hold on
% plot(x(Lvlm), y(Lvlm), 'vr')
plot(x, objfcn(B,x))
hold off
grid
text(25, 12, sprintf('$f(x) = %.3f \\cdot e^{%.3f \\cdot t} \\cdot cos(2 \\cdot \\pi \\cdot %.3f\\ t %+.3f) %+.3f$',B), 'Interpreter','latex', 'FontSize',11)
% xlim([0 50])
.
1 Comment
Alex Sha
on 8 Mar 2024
b(1) .* exp(b(2).*t) .* cos(2*pi*b(3)*t + b(4)) + b(5);
the results below will be little better:
Sum Squared Error (SSE): 3612.83461221834
Root of Mean Square Error (RMSE): 0.299830523951318
Correlation Coef. (R): 0.990716970140293
R-Square: 0.981520114923963
Parameter Best Estimate
--------- -------------
b1 -13.9887747654467
b2 -0.05066160816698
b3 -199.749779715466
b4 -3.01726078981019
b5 0.287608394237128
More Answers (0)
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!