Electrical – step response data extraction from response data of a model(simulink)

controlMATLABpid controllerstep response

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:enter image description here
thanks

Best 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