Extract Structure element dynamically

3 ビュー (過去 30 日間)
Life is Wonderful
Life is Wonderful 2019 年 11 月 1 日
コメント済み: Life is Wonderful 2019 年 11 月 2 日
I have structure whose elements name change dynamically with respect to result file name.
I need an example code which extract structure elements from structure joinedtimetable 'joinedtimetable.Properties.VariableNames'
I need them for plotting the data like
size = numel(joinedtimetable.Properties.VariableNames)
for i = 1:numel(joinedtimetable.Properties.VariableNames)
VariableNames = ExtractName(joinedtimetable.Properties.VariableNames(i);
end
subplot(size,y,i);plot(joinedtimetable.VariableNames(1),joinedtimetable.VariableNames(2));

採用された回答

Turlough Hughes
Turlough Hughes 2019 年 11 月 1 日
I would just convert it to a cell array which is easier to index through as you require
c=table2cell(timetable2table(joinedtimetable));
And then something like:
figure, hold on
for ii=1:size(c,2)
plot([c{:,ii}])
end
legend(joinedtimetable.Properties.VariableNames,'Interpreter','none')
How do you want to represent the non numerical data in your plots though??
  6 件のコメント
Life is Wonderful
Life is Wonderful 2019 年 11 月 1 日
Super thanks a ton!! Works well
Life is Wonderful
Life is Wonderful 2019 年 11 月 2 日
Can you please help me in getting the a GUI as well ?

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

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2019 年 11 月 1 日
%%
s.a=1:10;
s.b=rand(1,10);
EleNames=fieldnames(s);
plot(s.(EleNames{1}),s.(EleNames{2}));

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by