How to disallow string in block mask parameters?

1 回表示 (過去 30 日間)
Soham Sinha
Soham Sinha 2021 年 12 月 13 日
回答済み: Sanman 2022 年 1 月 27 日
How can I apply a constraint to a block mask parameter so that when a string is entered in the dialog block mask parameter, it is shown as an error? I could not find any option in Mask Parameter -> Constraint.
Also, how can I get the "evaluated" value of the block mask parameters in Initialization Commands? I am entering `b = get_param(block_handle, 'myparam1'), but getting a string for it. I want to get a double value and then compare to some value to show some error message.

回答 (1 件)

Sanman
Sanman 2022 年 1 月 27 日
Hi Soham,
Using mask parameter constraints, you can set the datatype you want for the mask parameter. I hope the following documentation can help you with that.
For your second question, you just need to use the function "eval" to do that.
b = eval(get_param(block_handle, 'myparam1'))
You can find the documentation for the function here - https://www.mathworks.com/help/matlab/ref/eval.html

カテゴリ

Help Center および File ExchangeAuthor Block Masks についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by