フィルターのクリア

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

1 回表示 (過去 30 日間)
CCC
CCC 2021 年 6 月 16 日
コメント済み: CCC 2021 年 6 月 22 日
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);

採用された回答

Yifeng Tang
Yifeng Tang 2021 年 6 月 18 日
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 件のコメント
CCC
CCC 2021 年 6 月 22 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEquations についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by