Simulink: How can I throw errors with the initialization commands in a masked subsystem?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello! I would like to evaluate parameters of a masked subsystem within the initialization code. The mask is created with the mask editor. The initialization code calls a m-function and passes the parameters of the block to this function. If e.g. the mass is negative, I wanto to display an error in the matlab command window.
if mass<0
error('mass is negative!')
end
If I use this code at the beginning of my initialization code, no error is displayed and the block doesn't initializes properly.
Does anyone know a solution? Thanks!
댓글 수: 1
Kaustubha Govind
2012년 10월 25일
Why not use the parameter callback function instead? That is probably the right place to validate parameters anyway.
채택된 답변
Martin
2012년 10월 26일
댓글 수: 2
Kaustubha Govind
2012년 10월 26일
Does this work:
hidden_block_cb(gcb,str2num(get_param(gcb, 'm')))
추가 답변 (2개)
Carlos
2014년 9월 18일
Hi,
I am having a similar issue, and I do not understand the proposed solution of using hidden_block_cb.
From the mask initialization tab I am trying to check the value of a variable. If loc == 999 I want to raise a warning. i.e. I want a warning to be shown in the Matlab command line. But using warning('message') or error('message') does nothing. Any ideas on how to do this? Thanks!
댓글 수: 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!