Difficulty solving for time constant and gain using the Signal Processing toolbox from a given data set

9 views (last 30 days)
I have an aircraft with a controller Setpoint (input, x(n)) for roll and have the corresponding roll response (output, y(n)) from the autopilot. I'm trying to fit a first order linear transfer function to the data to find the associated time constant for a parameter change.
I've found the fft of x(n) and of y(n) for X(s) and Y(s) respectively. Then used these functions to find the transfer function H(s)=Y(s)/X(s).
From here I'm not sure where to go or if I'm even on the correct track, any help would be grateful!
  3 Comments
Caleb
Caleb on 28 Apr 2023
You'll have to forgive me, my expertise in transfer functions and controls is limited. From my understanding taking the fft's would be "comparable" to taking the laplace or z transform of the data, just a different domain. Perhaps I am misunderstanding how to use the ztrans function, but I am having a hard time applying it or someting simiolar to discrete data rather than symbolic functions, or relating the symbolic functions to the data.
One other hang up is the only toolboxes I have access to are symbolics and signal processing, not system Identification unfortunately.
I've used tfestimate instead of tfest, but even it's output is throwing me off.
Paul
Paul on 28 Apr 2023
Edited: Paul on 29 Apr 2023
Taking the FFT's can be close to what you want, but it depends on the input used and the output generated. tfestimate is likely doing the same thing conceptually, but even it can have problems if not presented with the appropriate data.
Here's an example.
Define the numerator and denominator of a transfer function.
b = 1; a = [.1 1]; % H(s) = 1/(0.1s + 1)
Define the time vector
t = 0:.01:5;
Define a constant, step input.
u = 0*t+1;
Compute the output in response to the input, not accouting for what happens for t > 5 (requires Control System Toolbox)
y = lsim(tf(b,a),u,t);
Use tfestimate, no fancy options, and compare the result to the known frequency repsonse of H(s)
[Txy,wxy] = tfestimate(u,y,numel(y));
figure
w = logspace(-1,3,500);
h = freqs(b,a,w);
subplot(211);
semilogx(wxy/.01,db(abs(Txy)),w,db(abs(h))),grid
subplot(212)
semilogx(wxy/.01,angle(Txy),w,angle(h)),grid
Not such a good result.
Instead, use a chirp input and go through the same process.
u = chirp(t,.1/2/pi,2,100/2/pi);
y = lsim(tf(b,a),u,t);
[Txy,wxy] = tfestimate(u,y,numel(y),1);
figure
w = logspace(-1,3,500);
h = freqs(b,a,w);
subplot(211);
semilogx(wxy/.01,db(abs(Txy)),w,db(abs(h))),grid
subplot(212)
semilogx(wxy/.01,angle(Txy),w,angle(h)),grid
With the chirp input, tfestimate is much more successful. Some inputs are better than others if you're trying to estimate the transfer function of the system. And then the next step would be to come up with H(s) from the values in h.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB 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!