How do I have a time based function be the input for revolute joint position in Simulink

I am trying to model a motion in which I take data from the real world, regress it into a function and then use this function to drive a simulink model revolute joint for position. I then intend to use the model to do an inverse dynamics calculation of the joint torques that would be needed to create the specified motion.
What block do I use to just specify an input function to the joint as a function of time? I would like to be able to enter a polynomial equation with the regression coefficients.

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2022년 12월 1일
The Clock block provides the time line that the simulation runs on. You can use that for your function.

댓글 수: 3

This is the error I get when I use a Matlab function and the clock block feeding it the simulation time:
C Caller block 'RightArm90ByPositionInputUserDefinedFunctionAddedRE/Right Elbow Joint/User-Defined Functions/C Caller' requires model to have associated importable custom code. There is no custom code specified, or 'Import custom code' is disabled.
Suggested Actions
You may add custom code dependency to model 'simulink'Open
Enable 'Import custom code' for model 'simulink'
The error comes from a "C Caller" block, not a "MATLAB Function" block. For your need, I would think a "MATLAB Function" block is sufficient. Why use a "C Caller" block?
Thanks. I did not know there was a difference. The blocks look identical when I search for Matlab function. Must have had the wrong one. Now its on to a different error about input derivatives, but at least I am past that sticking point.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2022년 12월 1일

댓글:

2022년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by