Simulink model 'to workspace' output

2 次查看(过去 30 天)
I am trying to control motor torque and am using a workspace variable in Simulink and want to output similar variable to workspace.
I have size(T_u)=[3, 91] whereas the output I am getting from the simulation has size [101, 90]
I am unable to understand why this is so.
Code that I am using:
load('Motor_Param.mat')
t = 1:0.1:10;
T_o = [0.05*(10-t);0.04*(10-t);0.03*(10-t)];
T_d = zeros(size(T_o));
T_e = (T_d - T_o);
C_PD = pid(100,0,10,100);
T_u = zeros(size(T_e));
for k=1:size(T_e,1)
T_u(k,:) = lsim(C_PD,T_e(k,:),t);
T_l = zeros(size(T_u));
C_PI = pid(10,1000,0);
a = sim('Motor_Control','SimulationMode','normal');
out = a.get('T_l')
end
.mat and .slx files are attached.

回答(1 个)

Jesús Zambrano
Jesús Zambrano 2019-10-12
Hi Mohsina,
I see T_u matrix is loaded in you model using the From Workspace block. In this case each row of the matrix has time stamp in the first column, and the data in the rest of columns. In this particular example the data takes 90 columns. Then, the simulation runs using a variable step solver, it means that the step size varies from step to step, and it will depend on the model dynamics. You can see this variation when plotting
plot(out.Time(2:end),diff(out.Time));
Hope this answers your question.
Best,
Jesús

类别

Help CenterFile Exchange 中查找有关 Simulink 的更多信息

产品


版本

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by