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 CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by