Passing a non-integer value to a Simulink Block/Mask

6 ビュー (過去 30 日間)
Giorgi
Giorgi 2016 年 12 月 14 日
コメント済み: Giorgi 2016 年 12 月 24 日
Hello everyone,
I have made a custom Simulink block that is used as a UDP communication block for a custom target I built. One of the parameters I have to specify in the Mask (Or anywhere for that matter, but I want mine to be in the Mask), is the IP Address that messages have to be sent to. I am hoping to pass the IP address in the following format: 'xxx.xxx.xxx.xxx' however when I try that, I get a build error:
Expression 'IP_Adr' for initial value of data 'IP_Adr' must evaluate to a numeric or logical.
I've seen numerous Simulink blocks that accept IP addresses in the format above so there must be a way to do it, I am just not sure how. Any help would be appreciated!
Thanks in advance for any help!

回答 (1 件)

Kushagr Gupta
Kushagr Gupta 2016 年 12 月 20 日
I understand that you want to know how to pass an IP address as an input to a masked subsystem.
IP addresses can be stored or passed as strings in the MATLAB environment and thus enclosing the address in single quotes should help resolve the issue.
To illustrate with an example, let the IP address be 127.0.0.1, it can be specified in a mask as follows:
'127.0.0.1'
instead of
127.0.0.1
The second definition would result in an error related to unexpected expression.
Another way to pass this data could be to define a workspace variable as a character datatype and use that variable name in the mask.
>> IP_addr = '127.0.0.1';
Here, IP_addr was defined in MATLAB workspace and can be used as input to mask.
  1 件のコメント
Giorgi
Giorgi 2016 年 12 月 24 日
I tried that but I'm still getting errors for some reason. I'm feeding the input as a string '000.000.000.000' and I unchecked the "evaluate" option of the mask.
In the mask, I'm using an edit field with the evaluate box unchecked as mentioned above. Should I be using some other type of input?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEvent Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by