get_param fails with simscape block

1 次查看(过去 30 天)
Weird/unexpected behavior, not sure if it's a bug.
I'm trying to use get_param to access a stock simscape thermal component. If I do this using gcb, no problem. If I do it with bdroot, i don't get an answer.
>> get_param(gcb,'ClassName')
ans =
'cauer_model_element'
>> get_param(gcb,'resistance')
ans =
'3'
>> get_param(strcat(bdroot,'/Heat Sink/Sink'),'resistance');
>>
>> get_param(strcat(bdroot,'/Heat Sink/Sink'),'blahblah');
Cauer Thermal Model
Element block (mask) does not have a parameter named 'blahblah'
The last case where I try blahblah parameter is just to prove the path is correct. I also tried to retrieve 'ObjectParameters' - no answer.
I did a test to see if it had to do with being inside a subsystem (or if the space in the subsystem's name was an issue), but even a simscape component at the top level behaves the same way.
You can recreate this by making a new blank model, and plunking down any simscape component, and trying to access it's parameters from the base workspace command line.

采纳的回答

Walter Roberson
Walter Roberson 2022-2-10
>> get_param(strcat(bdroot,'/Heat Sink/Sink'),'resistance');
You put a semi-colon at the end of the line, and that means "execute the line but do not print the result" . Notice your first (successful) get_param did not have the semicolon

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating Custom Components and Libraries 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by