MATLAB Answers

- You will see updates in your activity feed.
- You may receive emails, depending on your notification preferences.

37 views (last 30 days)

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?

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.

Ill ch
on 4 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

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

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

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

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

Star Strider
on 31 Oct 2019

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

Opportunities for recent engineering grads.

Apply TodayUnable to complete the action because of changes made to the page. Reload the page to see its updated state.

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: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- 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)

## 4 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750854

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750854

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750863

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750863

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750868

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750868

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750874

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/482613-transfer-function-from-measured-input-signal-and-output-signal#comment_750874

Sign in to comment.