How do i transfer big symbolic equations into Simulink

조회 수: 79(최근 30일)
Sed 2016년 4월 18일
댓글: Walter Roberson 2022년 6월 25일 13:51
Hello everyone,
I am trying to solve the dynamics of a serial manipulator with 6DOF, and I want to transfer the result of an m file (vector of symbolic Torques) into a Simulink block and replace the symbolic variables with a vector of input to have the final numeric result as an output of the block.
I tried a Matlab function block but it does not support symbolic variables.
I tried to call the function as an extrinsic function but Simulink crashes every time I run it.
"from workspace" and "from m file" blocks are not what I need since I have an input to the block.
Any suggestions?
Thanks in advance.
  댓글 수: 3
Negin Borna
Negin Borna 2022년 6월 20일 20:01
Hello sed, I have same problem,can you explain how you fixed it?

댓글을 달려면 로그인하십시오.

채택된 답변

Ced 2016년 4월 19일
What do you mean by "matlab function does not support symbols"? Maybe I misunderstood your problem, but there is a function called matlabFunction, and it is specifically made to take symbolic expressions and turn them into "numerical functions".
Here is a small example for a 3DOF robot arm:
% Given: symbolic EoM dx = f(....)
syms q1 q2 q3 dq1 dq2 dq3 T1 T2 T3 real
q = [q1 q2 q3]'; % generalized coordinates
dq = [dq1 dq2 dq3]'; % derivative of generalized coordinates
T = [T1 T2 T3]'; % torque vector
% ... HERE: computation of EoM, returning symbolic dx = f(q,dq,T)
% now generate function
This will generate a file f_dyn.m with function
function dx = f_dyn(in1,in2)
where in1 = [ q ; dq ] and in2 = T
  댓글 수: 9
Walter Roberson
Walter Roberson 2022년 6월 25일 13:51
Please show the code for the function that reports that erroy

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by