Electrical – how to obtain the parameters of the step response within matlab in open loop

controlMATLABstep response

I have step response in open loop of my model that i stored in workspace and I want to use Matlab to obtain the: T time constant, L dead time and A (see figure below).is there a command for that like the stepinfo?
enter image description here
I have used it and as I am using a plant, I simulated the plant with step input and I did save the output Vout in timeseries as you showed me previously and made this script:

time=Vout.Time;  % x
Y=Vout.Data;   % y
For K, use the final value of Y
K = Y(end);
L_index = find(Y>=.05*K,1); 
L = time(L_index);
T_index = find(Y>=(1-exp(-1))*K,1);
T = time(T_index);
D = diff(Y)./diff(time);
inflex = find(diff(D)./diff(time(1:end-1))<0,1);
A = D(inflex)*time(inflex)-Y(inflex);

tangent = D(inflex)*time - A;
plot(time,Y), hold on, plot(time,tangent), plot(L,Y(L_index),'*'), 
plot(T,Y(T_index),'*') 

it calculated every parameters (L,T and A) but the result look like: enter image description here description here does the modification i included are right despite not seeing the tangent?

Best Answer

An example system and its step response:

s = tf('s');
SYS = 1/(s^2+s+1);
[Y,time] = step(SYS);

For K, use the final value of Y.

K = Y(end);

For L and T, use an amplitude threshold criteria. Here I consider L to be when amplitude goes above 5% the final value, and T when it goes above 63%.

L_index = find(Y>=.05*K,1);
L = time(L_index);
T_index = find(Y>=(1-exp(-1))*K,1);
T = time(T_index);

Use diff twice to detect the inflexion point, determine tangential line slope and the negative of its linear coefficient is equal to A.

D = diff(Y)./diff(time);
inflex = find(diff(D)./diff(time(1:end-1))<0,1);
A = D(inflex)*time(inflex)-Y(inflex);

Now a plot to prove all is in order.

tangent = D(inflex)*time - A;
step(SYS), hold on, plot(time,tangent), plot(L,Y(L_index),'*'), plot(T,Y(T_index),'*')

enter image description here