Automatic Creating Data Tips in loop for struct array

2 次查看(过去 30 天)
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 ?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by