Automatic Creating Data Tips in loop for struct array

4 Ansichten (letzte 30 Tage)
Evgeny Fedorov
Evgeny Fedorov am 29 Okt. 2019
Hi)
Could anyone help me to solve this problem?
I have a struct array with fields, and now I need to create datatips automaticly for each field
s.DataTipTemplate.DataTipRows(1).Label = selectedItemX; % create X == to selected field of struct on plot
s.DataTipTemplate.DataTipRows(2).Label = selectedItemY; % -------same for Y
% - This is how its work manually
% s.DataTipTemplate.DataTipRows(4) = dataTipTextRow('Node',handles.S.Node);
% s.DataTipTemplate.DataTipRows(5) = dataTipTextRow('Fmin',handles.S.Fmin);
%.....for all other fields
% my suggestion how it's must work
fn = fieldnames(handles.S);
% my loop for
for datatipindex=1:(length(fieldnames(handles.S)))
s.DataTipTemplate.DataTipRows(end+1) = dataTipTextRow(fn(datatipindex), handles.S.(datatipindex)); % I know it's not correct for struct
end
% So how make this work, or any other solution ?

Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by