Passing a non-integer value to a Simulink Block/Mask
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponses (1)
Kushagr Gupta
le 20 Déc 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.
Voir également
Catégories
En savoir plus sur Event Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!