필터 지우기
필터 지우기

Simulink model 'to workspace' output

조회 수: 3 (최근 30일)
Mohsina Zafar
Mohsina Zafar 2019년 7월 4일
답변: Jesús Zambrano 2019년 10월 12일
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에서 Classical Control Design에 대해 자세히 알아보기

제품


릴리스

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by