Retrieve a list of simscape.logging.Node names from simlog or other inner nodes

2 visualizzazioni (ultimi 30 giorni)
How do you retrieve as a cell, strings or other indexable array a list of nodes in the simlog?
example:
ssc_dcmotor
sim('ssc_dcmotor');
that returns
simlog_ssc_dcmotor
I want an array:
list(1) = 'ERef';
list(2) = 'DC_Motor'
list(3) = 'DC_Voltage';
etc.
From there I could call or similar.
eval('simlog_ssc_dcmotor.list(2)')
The same with 'DC_Motor' (which would be list(2))
how do I generate a list of its simscape.logging.Nodes of 'DC_Motor'?
MATLAB comes with print(simlog_ssc_dcmotor.) but you cannot store it like:
a = print(simlog_ssc_dcmotor);

Risposta accettata

Yifeng Tang
Yifeng Tang il 18 Giu 2021
fieldnames(simlog_ssc_dcmotor) seems to work OK for me. Same way you would get the names of a structure variable.
ssc_dcmotor
sim('ssc_dcmotor');
list = fieldnames(simlog_ssc_dcmotor);
% list =
%
% 10×1 cell array
%
% {'id' }
% {'savable' }
% {'exportable' }
% {'ERef' }
% {'Sensing' }
% {'Load_Torque' }
% {'DC_Voltage' }
% {'DC_Motor' }
% {'MRRef_Motor' }
% {'MRRef_Torque'}
Just ignore the first three.
  1 Commento
CCC
CCC il 22 Giu 2021
It worked like a charm with eval to create the lists of sub components and retrieve values().
I find rather strange to use that method if you don't know the names of the components a prori.
Thank you very much.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Equations in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by