curve fitting to step and impulse response

27 visualizaciones (últimos 30 días)
Huichen Zhang
Huichen Zhang el 4 de Abr. de 2017
Respondida: Sanjay Manohar el 4 de Sept. de 2019
I am trying to curve fit a step response and an impulse response curve of a second order system. While the step response I know that its hard to fit due to external noises, I dont understand why for the impulse response, Matlab curve fitting toolbox is unable to fit the curve.
I have attached the original data here. 278800:324000 is the data corresponds to impulse response.
% how to use this code?
% 1. type in .xlsx file path in line 10
% 2. modify the first entry in line 16 and 17 to select valid data
% 3. run the code. A, B, and C are stored in the array newparams
% Sample sheet is used in this data.
% Define curve model functions
expsin = @(A, B, C, t)A * sin(C * t) .* exp(-B * t);
lsqexpsin = @(p, t)expsin(p(1), p(2), p(3), t);
% read data from file
filename = 'C:\Users\huich\Dropbox\EG4301\Testing\Heavydampedfiring\firing1.xlsx';
data = xlsread(filename);
% Store data in arrays
x = data(278800:324000,2);
t = data(278800:324000,1);
x = x - 0.5;
t = t - t(1);
dt = 10;
close all; figure; hold on;
plot(t, x, 'k-', 'LineWidth', 2);
% Count zero crossings to find frequency
zCross = find(x(1:end-1) .* x(2:end) < 0);
T = mean(diff(zCross) * dt) * 2;
fEstimate = 1 / T;
C = 2 * pi * fEstimate;
% Fit model to data
init = [0.5, .5, C];
[newparams, err] = lsqcurvefit(lsqexpsin, init, t, x);
plot(t, lsqexpsin(newparams, t))
I dont know whats wrong with the code either as it doesnt give a decaying oscillation function. Original file can be downloaded from, https://www.dropbox.com/s/9o7ip4490kavt4l/firing1.xlsx?dl=0

Respuestas (2)

prabha verma
prabha verma el 25 de Abr. de 2019
Probably you are taking wrong equation.
For finding correct equation, find out the time response signal relation ship of the second order system. Since your data belongs to the underdamped condition, So considere the respactive equation.
in this pdf please got to page 10, the very first equation on this page may be your curve fitting wquation. You need to define the damping factor and natural frequency using some initial guess.
It would be even more easier if you use the "cftool" of matlab.
Hope it will help

Sanjay Manohar
Sanjay Manohar el 4 de Sept. de 2019
The data and the fit start 90 degrees out of phase!
You probably need a phase term.
sin(dx+c)
If you know the curve is constrained to start at +1, then just use cos(dx) instead of sin(dx+c).

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by