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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!