Using set_param to change parameter DataTypes in Packet Input block does not work.

1 次查看(过去 30 天)
I am using the block Packet Input to receive CAN messages.
I have several of these blocks and I can change the parameter Sampletime by using this command:
set_param('.../.../Packet Input','SampleTime', '0.01')
However, when I want to change the parameter DataTypes it does not work:
set_param('.../.../Packet Input','DataTypes', 'double')
I get this error:
"Non-string expression where a string was expected."
Even though both parameters have the same properties:
>> ans.SampleTime
ans =
Type: 'string'
Enum: {}
Attributes: {'read-write' 'read-only-if-compiled' 'link-instance'}
>> ans.DataTypes
ans =
Type: 'string'
Enum: {}
Attributes: {'read-write' 'read-only-if-compiled' 'link-instance'}
How do I set the DataTypes parameter in the Packet Input block via set_param()?

采纳的回答

Sandip Kumar
Sandip Kumar 2014-10-8
In order to specify the DataTypes, try using ''double'' instead of 'double'.
Thanks, Sandip, MathWorks
  2 个评论
Markus Nordstrand
Markus Nordstrand 2014-10-9
Aha I see now. It was almost right, in order for Matlab to interpret a single quote as a sign I have to write '' according to this, which means that if I want to send the string 'double' to the packet input parameter setting, I have to use '''double''', aka tripple single quotes.
This works! Thank you very much for the input!
/Markus

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by