Using global variable to define a Simulink block parameter
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, i guess it should have been simple but i cant find a solution since long time. I have a simulink model that has a "Matlab function" block. I have a parameters' function that i load each time automatically using simulink Callbacks=> InitFcn. I want my Matlab functin block to take its Sample time parameter defined in this init function, but it does not work.
but when i define the parameter manually in the matlab workspace, the block takes it.
any ideas !!
thanks in advance,
aft kh
댓글 수: 0
채택된 답변
Fangjun Jiang
2011년 11월 23일
In the InitFcn call, does it call a M-function or M-script? I suspect this is another case of function workspace and base workspace.
Clear the base workspace using "clear", then run whatever is in the InitFcn. Then check the base worksapce, do you see the sample time parameter?
As you indicated, you need to set the sample time parameter in the MATLAB base workspace.
댓글 수: 0
추가 답변 (2개)
Kaustubha Govind
2011년 11월 23일
When you update your model, is that parameter created in the base workspace? Make sure that you the place where you define the parameters is a script and not a function (in which case, the variables are created in the function workspace and deleted as soon as the function returns).
If you do see the parameter created in the base workspace, then this should work. What is the error that you see?
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interactive Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!