0
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ You should use the "To Workspace" block in simulink. I believe you misunderstood the example given. \$\endgroup\$ – Vicente Cunha May 24 '18 at 8:11
  • \$\begingroup\$ 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) \$\endgroup\$ – Yaakov May 24 '18 at 8:22
  • \$\begingroup\$ 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. \$\endgroup\$ – Vicente Cunha May 24 '18 at 8:26
  • \$\begingroup\$ 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. \$\endgroup\$ – Yaakov May 24 '18 at 8:32
  • \$\begingroup\$ 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. \$\endgroup\$ – Vicente Cunha May 24 '18 at 8:44
0
\$\begingroup\$

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
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.