Simulink - vary which part of a structure is accessed in a matlab function block (using a bus)
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
Within a matlab function block can I dictate what part of a structure is accessed based on one of the function blocks inputs?
I am using an embedded 'matlab function' block in simulink to control the value of a force. The force depends on time and 1 other parameter (that I have called 'which_force'). The various values for Force are contained in a structure. I use a bus to grant Simulink access to the structure.
The structure looks like:
Forces.which_force1.Heave
Forces.which_force2.Heave
Here is a simplified version of the code:
function F_Heave = get_force(Forces, Clock, which_force)
F_Heave = Forces.(which_force).Heave(Clock)
An error occurs with (which_force) that states:
'Non-constant expression or empty matrix. This expression must be constant because its value determines the size or class of some expression. In this context, the value of the string must be known.'
I have also applied which_force from a constant block and I still receive the same error message.
댓글 수: 0
채택된 답변
Kaustubha Govind
2013년 10월 9일
I think the only way this code might work is if the variable which_force is configured as a non-tunable parameter of the block, instead of as an input signal.
댓글 수: 5
Ketan
2013년 10월 20일
Hi Leo,
If you are evaluating the performance of a model containing MATLAB Function blocks, you may want to disable debugging for the MATLAB Function blocks. By default they are configured for debugging. See the following page for information on controlling function block debugging:
Ketan
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!