How to obtain transfer function coefficients from data plot?
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
Star Strider
le 11 Déc 2020
1 vote
‘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 commentaires
Derek Johnson
le 11 Déc 2020
Modifié(e) : Derek Johnson
le 11 Déc 2020
Star Strider
le 11 Déc 2020
I’m not certain what you’re doing. Since you specified a time vector ‘t’, see if using:
- y = resample(x,tx) resamples the values, x, of a signal sampled at the instants specified in vector tx. The function interpolates x linearly onto a vector of uniformly spaced instants with the same endpoints and number of samples as tx. NaNs are treated as missing data and are ignored.
will do what you want. (There is no specific link to that resample section.) Noite that there are other options.
I usually specify a sampling frequency, and let the function calculate everything else, using:
with ‘tx’ being the original vector of sampling times. Use the same ‘t’ vector to resample both vectors. That should work. See the function documentation for details. Experiment to understand what the function is doing.
Derek Johnson
le 13 Déc 2020
Star Strider
le 13 Déc 2020
The code appears to be correct.
The problem may be the sampling frequency of 1800. You have 75 samples going from 0 to 1800 seconds.
I would begin with:
Fs = 1/mean(diff(AFR_time));
then round that up to an acceptable value (so if that is about 75/1800=0.042 samples/second round it up to either 0.05 or 0.1), and use that instead of 1800.
Derek Johnson
le 13 Déc 2020
Star Strider
le 13 Déc 2020
To determine the number of poles and zeros (and their approximate locations), calculate the Fourier transform of the time-domain isgnal, then plot only the imaginary part of the signal as a function of frequency. The pole locations will be the peaks (or at least the positive extrema), and the zeros will be the zero-crossings. This will at least tell the number of poles and zeros. Note that it could also reveal if there are poles or zeros at 0 or at +Inf, so it may be necessary to count those as well.
This should work, although in certain situations, it can be a bit ambiguous and require some interpretation in the context of what you know about the system.
This is the most reliable way I know of to estimate the number and approximate locations of the poles and zeros with any precision.
Derek Johnson
le 13 Déc 2020
Star Strider
le 13 Déc 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.
Catégories
En savoir plus sur Transfer Function Models dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




