I simulated the following function on matlab. now trying to simulate it on simulink. in the uploaded image the simulink block structure can be seen where i assumed a constant for (Tb),but i should implement it as a function shown in the matlab text.
2 次查看(过去 30 天)
显示 更早的评论
function dudt = first_order2(u,kd,cd,ct,Tt,Jt,Jb,WOB,Ls,Lk,Ld,Lstr)
% u(1) = ot; u(2) = wt; u(3) = ob; u(4) = wb
%R = 0.0492;
%dc = 3.7186;
Tst = cd * (u(2) - u(4)) + kd *(u(1) - u(3));
Tcf = (2/3) * Ls * WOB;
%if u(4) * Ld <= 0.3
% fun = @(r) 2 * WOB / R^2 * (r.^2. * ((Lk/R) + ((Ls/R) - (Lk/R))*exp(-dc*u(4)*r)));
% Tdr = integral(fun,0,R);
%else
Tdr = ((2/3) * Lk * WOB) + (2 * WOB * (Ls - Lk) / (Ld^3 * u(4)^3)) * (2 - exp(-Ld*u(4)) * (Ld^2 * u(4)^2 + 2 * Ld * u(4) + 2)) + (0.5 * WOB * Lstr * u(4));
%end
if abs(u(4)) <= 0.001 && Tst < Tcf
Tb = sign(u(4))*Tst;
elseif abs(u(4)) <= 0.001 && Tst >= Tcf
Tb = sign(u(4))*Tcf;
elseif abs(u(4)) > 0.001
Tb = sign(u(4))*Tdr;
end
dudt = zeros(4,1);
dudt(1) = u(2);
dudt(2) =(-(cd + ct) * u(2) + cd * u(4) - kd * u(1) + kd * u(3) + Tt) / Jt;
dudt(3) = u(4);
dudt(4) = (cd * u(2) - cd * u(4) + kd * u(1) - kd * u(3) - Tb) / Jb;
end
0 个评论
采纳的回答
Aquatris
2018-7-17
You have a couple options for implementing the Tb variable. One possibility is to use Switch Block to mimic the if conditions. Another one is to use Matlab Function Block and type your if statements inside to change Tb values.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pole and Zero Locations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!