get_param fails with simscape block

3 visualizaciones (últimos 30 días)
Matthew Mishrikey
Matthew Mishrikey el 10 de Feb. de 2022
Comentada: Matthew Mishrikey el 10 de Feb. de 2022
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Feb. de 2022
>> 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

Más respuestas (0)

Categorías

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

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by