# step response data extraction from response data of a model(simulink)?

I want to design a PID controller with the step response method, so I needed to save the step response of my model in simulink in workspace (Vout) with saved format :structure wih time, I exctracted the time value by using the command

t=Vout.time


and signal value as:

y=Vout.signals


then run the command to exctract the data to matlab:

load StepInfoData t y


so I can analyse it by calling the function plot(t,y) and S1 = stepinfo(y,t,0.4) but it shows the error following

Warning: Variable 'y' not found.

Warning: Variable 't' not found.

and the same for plot function. actually, I am not sure if the workspace is the correct method to save the data. link:https://se.mathworks.com/help/control/ref/stepinfo.html#mw_cab22a5a-b8ef-49fd-b071-3e7888430c00 the model looks like: thanks

• You should use the "To Workspace" block in simulink. I believe you misunderstood the example given. – Vicente Cunha May 24 '18 at 8:11
• I used exactly "to workspace" and changed the t and y to other variable like a and b and still not working.(i edited the post) – Yaakov May 24 '18 at 8:22
• But then why do you use "load StepInfoData t y"? You just need to run the simulation and plot the data. plot(Vout) should do the trick. – Vicente Cunha May 24 '18 at 8:26
• I used because in he link it say you save the data then call the commands "load StepInfoData t y". I runt the commant now Plot(Vout) and shows this error:>> plot(Vout) Error using plot Not enough input arguments. – Yaakov May 24 '18 at 8:32
• Use the "Timeseries" option instead of "Structure with time". It works fine with Timeseries, just tested. Also, that "load ..." line in the link is particular to that example, it makes no sense in your context. – Vicente Cunha May 24 '18 at 8:44

## 1 Answer

To export signals from simulink to the matlab workspace, use the "To Workspace" block. One of the more relevant options of the block is the specification of format of the exported variable. When using the Timeseries format to export a variable named simout, data can be plotted using:

plot(simout)


To retrieve data and time arrays from Timeseries into separate variables, use:

data = simout.Data
time = simout.Time