MATLAB Answers

Simscape custom component to have one parameters unit change depending on the input of another parameter

조회 수: 1(최근 30일)
Kostas
Kostas 21 Oct 2019
Edited: Kostas 21 Oct 2019
Hi all,
I am creating a custom simscape block and it all works fine, except the units. The equation is Torq = D1*w + D2*w^PE and the parametres I declare are D1, D2 and PE (w is the rotational velocity). Therefore you can see that if I delcare PE to be 2.5 for example, then this implies that the units of D2 will have to change accordingly to make D2*w^PE be equal to N*m (Newton meters).
I tried implementing the change in units by using a typical sprintf function, however as Simscape laguage appears to be its own thing, it doesn' seem to be working... So do you have any ideas on that?
Here is the code for the component:
component propeller_law
% The equation is Torq = D1*w + D2*w^PE, where:
nodes
r = foundation.mechanical.rotational.rotational; % R
c = foundation.mechanical.rotational.rotational; % C:right
end
parameters
PE = 2.5 ; % Exponent
D1 = { 0.001, '(N*m)*s/rad'}; % Linear Damping Coefficient
D2 = { 0.001, sprintf('(N*m)*(s/rad)^%f',PE)}; % Non-Linear Coefficient
end
variables
w = { value = {0, 'rad/s'}, priority = priority.high }; % Angular Velocity
theta = { 0, 'rad' }; % Angular Displacement
t = { 0, 'N*m' }; % Torque
end
branches
t : r.t -> c.t; % torque through from node r to node c
end
equations
assert(D1>=0 && D2>=0) % Damping coefficients must be positive
w == r.w - c.w;
t == D1*w + D2*w^PE ;
w == theta.der
end
end
Kind Regards,
KMT.

  댓글 수: 0

로그인 to comment.

답변 수 (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by