Automatic Creating Data Tips in loop for struct array

2 views (last 30 days)
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 ?

Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!