You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Transfer function from measured input signal and output signal
18 views (last 30 days)
Show older comments
Dear Matlab and Simulink user,
Is there any way with parameter estimation toolbox or any another method to generate transfer function from multiple inputs and multiple outputs Signals?
4 Comments
Star Strider
on 28 Sep 2019
I never attempted to identify a MIMO system, although I suppose it is possible. (I cannot find any reference to MIMO system identification in the documentation.) See: Supported Continuous- and Discrete-Time Models for a discussion.
Ill ch
on 28 Sep 2019
Dear Star STrider,
Great your kind help.
Thank you very much for this link. Yes i found their solution for multiple input output.
with iddta one can generate data for tfest. y and u one can give as a matrix form.
Ill ch
on 28 Sep 2019
one small query if you can help me:
if i have in output signal (data1 as a time, data 2 with value) and in input signal ( data 1 just value) how i can use this ? should i need to use in bothe same time vector or sampling time is enough instead of time vector? Thank you in advance
sys = tfest(data,np,nz) ; % data from iddata(y,u,Ts)
Accepted Answer
Star Strider
on 28 Sep 2019
The sampling interval ‘Ts’ is enough. Note that all your data must be sampled all with the same sampling interval. If they are not, you need to interpolate them to the same sampling interval with the resample function first.
I usually calculate the sampling interval as:
Ts = mean(diff(time));
For iddata, the output signal ‘data2’ is ‘y’, the input signal ‘data1’ is ‘u’, and ‘Ts’ is as I described it.
32 Comments
Ill ch
on 4 Oct 2019
Edited: Ill ch
on 5 Oct 2019
Hello Star,
I generated with two experiment transfer function. And results came well. Thank you for your explanation.It is Non linear model.
I have one question regarding validation for it. I want to give this generated mathematic transfer function again same input signal and want to get output signal.
Is it possible? could you plz help me. Attached my merge experiment data.
Ts = 1.67000668002672e-07; % mean(diff(t));
np=2;
nz=1;
iodelay = [];
sys = tfest(new,np,nz,iodelay,'Ts',Ts) ; % data from iddata(y,u,Ts)
sysc = d2c(sys);
Star Strider
on 5 Oct 2019
I was doing other things for most of the day yesterday.
I believe you want to simulate it.
In order to simulate your model using lsim so I can see what it does, I had to create a time vector because lsim wants one. It appears to be correct. I then used ‘u1{1}’ in the simulation, since I do not have a good idea what ‘new’ represents.
Try this:
D = load('data_collection_new_two_experiment.mat');
new = D.new;
Ts = new.Ts;
% Q = get(new); % See What’s Inside ...
u1 = new.InputData;
U1 = u1{1};
U2 = u1{2};
t = linspace(0, numel(u1{1}), numel(u1{1}))*Ts{1};
Ts = 1.67000668002672e-07; % mean(diff(t));
np=2;
nz=1;
iodelay = [];
sys = tfest(new,np,nz,iodelay,'Ts',Ts) ; % data from iddata(y,u,Ts)
sysc = d2c(sys);
[y,t] = lsim(sysc,u1{1},t(:));
figure
plot(t, y)
grid
I would experiment by increasing the numbers of poles and zeros to see what gives you the best results, since there appears to be a resonance at the end of the simulation that (if I remember correctly) does not appear in your original signal. Adding a single extra pole, increasing ‘np’ to 3 (the extra pole would appear at 0 Hz and so have only a real component), actually appears to reproduce your signal a bit better.
As for comparing the data with your simulation, plot them against one another. The straighter the line, and the closer the slope to 1, the better the simulation. This is qualitative rather than quantitative, however it gives you an easy way to visually compare them. (You can use quantitative approaches, such as correlation, later to numerically assess the comaprison.)
I may not understand your data well enough to re-create what you intend, so experiment to get the result you want.
Star Strider
on 5 Oct 2019
I would experiment with fewer poles and zeros.
Also, you mentioning ‘filtering’ the output. I am not certain how you are filtering it, however note that the filter function itself introduces phase delay and phase distortion, as do most filters, the hardware Bessel filter being the exception. (The filtfilt function is therefore preferable for discrete filtering.)
Star Strider
on 5 Oct 2019
I intended that you resample the data if the sampling intervals were not all the same. Essentially everything involving discrete data including filtering, control, and system identification, requires that the sampling intervals not change, and that the sampling interval be known.
Star Strider
on 5 Oct 2019
That looks to me to be reasonably good (looking only at the images you posted).
Note that by definition:
Fs = 12000;
Ts = 1/Fs;
so ‘Ts’ is not the same as the one you posted, given ‘Fs’.
Star Strider
on 6 Oct 2019
I am not certain what you are doing with the code you posted.
The point is that the sampling frequency ‘Fs’ and the sampling interval ‘Ts’ must be the reciprocals of each other. You may have to adjust the number of poles and zeros (or other parameters) to get your identified system to model your signal appropriately.
Ill ch
on 21 Oct 2019
Dear Star,
I have one question regarding simulating transfer function. I have multi experiment based transfer function. 100 inputs vs 100 outputs (based on 100 measurements). I want to simulate it all in one time like i give 100 inputs to transfer function and getting 100 outputs from it. Currently i am doing it manually like i am giving 1 input getting 1 output same for all. Is it possible to give in one time all 100 inputs and getting bunch of 100 outputs from it?
Thank you
Star Strider
on 21 Oct 2019
Not to my knowledge. You most likely would have to do this in a loop, with one iteration for each input, since the transfer fucntion is a SISO system.
Ill ch
on 23 Oct 2019
Dear Sir Star,
I have one small question based on multiple experiment on Transfer function with discret time and continous time.
I found out my results are good with continus time TF instead of discret time TF as my data is discret.
Is it possible scientifically to modelled TF for data( which are with discret time) in continus time Transfer function?
Thank you very much in advance
Star Strider
on 23 Oct 2019
I am not certain what you are doing, since continuous time models are usually implemented in hardware, and discrete time models are used with sampled signals.
Use whatever works best.
Ill ch
on 29 Oct 2019
Dear Star,
I need one small help from you. I have output data in iddata form.
K>> y{1}
ans =
Time domain data set with 500 samples.
Sample time: 8.3333e-05 seconds
Name: TransferFunction_Object
Outputs Unit (if specified)
y1
I need to extract from this data the value of the y1 as a vecor form. and then i want to convert it to cellstr from numstr.
Could you please help me? I tried this
cellstr(num2str(y{16}))
Error using num2str (line 53)
Input to num2str must be numeric.
Thank you very much in advance
Ill ch
on 29 Oct 2019
Thank you very much for your response
Name Size Bytes Class Attributes
y 1x38 342362 cell
y =
1×38 cell array
Columns 1 through 5
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 6 through 10
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 11 through 15
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 16 through 20
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 21 through 25
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 26 through 30
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 31 through 35
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Columns 36 through 38
{500×1×0 iddata} {500×1×0 iddata} {500×1×0 iddata}
Star Strider
on 29 Oct 2019
I am still lost. I have no idea what you are doing, or what you want.
Perhaps this example will demonmstrate how do what you want:
data = iddata(rand(1,10)', (0:9)', 0.1); % Create ‘iddata’ Object
y = data.OutputData; % Get ‘OutputData’ As Double Array
with:
whos y
producing:
Name Size Bytes Class Attributes
y 10x1 80 double
Ill ch
on 29 Oct 2019
Edited: Ill ch
on 29 Oct 2019
I can explain in simple word:
Name Size Bytes Class Attributes
y 1x38 342362 cell
y is 1x38 cell arry. That means it contains 38 output values data vector. I want to have that all vectors in normal double form so that i can check the values of each. As well as i want to convert that from
ycs = cellstr(num2str(y{1})); % y{1} is not working as it works in your demonstrated code because your example
%is for one single data vector
% data = iddata(rand(1,10)', (0:9)', 0.1);
% y = data.OutputData;
% ycs = cellstr(num2str(y));
Error
cellstr(num2str(y{16})) % y{16} is the 16th data vector from y-cell array
Error using num2str (line 53)
Input to num2str must be numeric.
I hope you got my point. Thank you very much in advance for kind support and best regards
Ill ch
on 31 Oct 2019
Edited: Ill ch
on 31 Oct 2019
Dear Star,
I have question regarding sampling interval TS. as you had suggested me resampling if sampling interval not same. I have input data (600 points) which has Fs=16000 and output data (600 points) which has Fs=60000 and output has time vector also) Is it possible to give sampling interval for both Ts=1/Fs based on input data? in order to create transfer function.
Star Strider
on 31 Oct 2019
I do not understand. How is it possible to have an input sampling frequency of 16000 Hz and and output sampling frequency of 60000 Hz with the same size (600 element) vector for each?
If the vectors lengths were proportional to the sampling frequency, the resample function would work to equalise them (using the 16000 Hz sampling frequency).
This problem likely has no solution.
Ill ch
on 31 Oct 2019
Edited: Ill ch
on 31 Oct 2019
This problem arrives during measurements as when i am applying input signal with 600 points and Fs=16000 but the output measurement from real system has 60,000 Hz Fs. I done almost 200 measurements and suddenly i realize that output has not same Fs like input. I am confuse how to solve this problem to create tfest
Star Strider
on 31 Oct 2019
I doubt that a solution exists for it. This appears to be an experiment instrumentation problem that nothing in MATLAB can slavage.
Ill ch
on 31 Oct 2019
Sorry my mistake in writing:
Input signal: N=600; Fs=16000
Output signal; N=12000; Fs=50000
Is it possible to resample this? Thank you very much in advance
Star Strider
on 31 Oct 2019
The best approach would be to resample the output signal as:
[NewOutput, NewTime] = resample(output,output_time_vector,16000);
or something similar.
It is likely more accurate to downsample the signal with the higher sampling frequency to a lower sampling frequency than the reverse of that. Even after that, there remains the problem of the lengths not being equal, so there would not be a one-to-one correspondence of the input and output vectors.
It would be best to repeat the experiment, this time sampling the input and output at the same sampling frequencies so that the experiment produces reliable data and equivalent-sized vectors. It is likely not possible to salvage the present data and get anything close to a meaningful result. Repeating the experiment is likely the only option.
Ill ch
on 2 Nov 2019
thank you very much for detailed useful information. Yesterday i was thinking on this problem. I found one solution :
for example:
Input signal: Ts= 0.0000733
After resmapling Output signal Ts= 0.00007
I took the round figure for both Ts=0.00007. I do not know either it is possible in research work but i feel that is the solution which i can do. Your comment will be helpful for me on rounding the Ts.
Star Strider
on 2 Nov 2019
It may not be necessary to round it. In any event, if you want to, the easiest way to create it with:
Ts = 0.00007
is likely to use resample with
p = 700
q = 733
or the reverse of these, depending on what you started with and what you want as an output.
Ill ch
on 17 Dec 2019
Hello Star,
Could you please help me for the following question?
Thank you very very much in advance
More Answers (0)
See Also
Categories
Find more on Transfer Function Models 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)