Automatic Creating Data Tips in loop for struct array

2 vues (au cours des 30 derniers jours)
Evgeny Fedorov
Evgeny Fedorov le 29 Oct 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 ?

Réponses (0)

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by