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

6 visualizaciones (últimos 30 días)
Giorgi
Giorgi el 14 de Dic. de 2016
Comentada: Giorgi el 24 de Dic. de 2016
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!

Respuestas (1)

Kushagr Gupta
Kushagr Gupta el 20 de Dic. de 2016
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 comentario
Giorgi
Giorgi el 24 de Dic. de 2016
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?

Iniciar sesión para comentar.

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by