How to obtain transfer function coefficients from data plot?

16 views (last 30 days)
Hi all,
I am trying to model the air fuel ratio response to different NOx inputs, and I would like to obtain my system of ODE's from this data.
NOx_i = readtable('NOxIN.csv');
AFR_o = readtable('afrOUT.csv');
AFR_time=AFR_o{:,1};
AFR_val=AFR_o{:,2};
save('AFRout.mat','AFR_time','AFR_val');
load('AFRout.mat','AFR_val');
[AFR_num,AFR_den] = tfdata(AFR_val);
I have extracted the data points and imported them to matlab using readtable, currently as two seperate tables containing time and NOx, and time and AFR. I am currently trying this code to get the transfer function coefficients, but I don't think I am giving the tfdata function the proper input type. It needs to recieve a dynamic system input, but I'm unsure how to get my two tables and data sets into a system that can be read by tfdata.
Any help or suggestions would be greatly appreciated!

Accepted Answer

Mathieu NOE
Mathieu NOE on 9 Dec 2020
hello
you need to use tfest
sys = tfest(data,np) estimates a continuous-time transfer function sys using the time-domain or frequency-domain data data and containing np poles. The number of zeros in sys is max(np-1,0).
just looking at the curves , it seems the relationship between the two is a simple as a first order polynomial (because the two curves are very similar only mirrored)
so if it does not work with tfest , I would try to fit a polynomial
  2 Comments
Derek Johnson
Derek Johnson on 10 Dec 2020
I believe my data sets must be continous in order to make them a system. Right now my two time sets have different sampling times, but the same start and end. Meaning the AFR has data points at 0,21,72,143,178 seconds and the NOx has points at 0,14,49,90,178 (these are just random numbers to try to communicate the issue), I dont think tfest is working because my system isn't properly defined as a result of these different time inputs. Is there any way I can get these two sets of data on the same continous time domain?

Sign in to comment.

More Answers (1)

Star Strider
Star Strider on 11 Dec 2020
Is there any way I can get these two sets of data on the same continous time domain?
Use the Signal Processing Toolbox resample function on both signals using either the same time vector, or the same sampling frequency (these are both options). After that, you should be able to use the System Identification Toolbox funcitons with the resampled signals.
  8 Comments
Derek Johnson
Derek Johnson on 13 Dec 2020
I think I am confused I how to get the Fourier transform of the time-domain signal. The tf gives me the num and den in laplace, then I am trying to get the tf into the time domain, and then plug in t values till 1800 seconds, then get the fft of that response. What am I misunderstanding here? I believe the error is that I cant plug t values into the t_sig because it is 1x1 sym, but I am not sure what else to try.
Here is my relevant code, workspace, and what t_sig is. Thanks for any help!
%% transfer function estimation
sys = tfest(data,2);
%sys2 = tfest(data,1);
[num,den] = tfdata(sys);
syms s
num_poly = poly2sym(cell2mat(num),s);
den_poly = poly2sym(cell2mat(den),s);
G_poly = num_poly/den_poly;
t_sig = ilaplace(G_poly);
t = (0:1:1800);
time_response = t_sig(t);
fft = fft(time_response);
Star Strider
Star Strider on 13 Dec 2020
I suggested plotting the imaginary component of the Fourier transform in order to estimate with reasonable accuracy the number of poles and zeros if the system you are identifyting. It likely has no other utility than that, since the Bode plot of the identified system will simulate it for you and plot the estimated transfer function.
Use the compare function to see how well the identified system matches the original data.

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!