How to put some string in a variable?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone ,
i have a question about this code :
function fonction_graphs_1(handles)
val = get(handles.graph,'Value');
str = get(handles.graph,'String');
switch str{val};
case 'Electrique'
set (handles.graph_1,'Enable','on');
nameList = {'modele_'};
for iIndex = 1:10
Field = sprintf('%s%d', nameList{1},iIndex);
if findobj('Tag',Field,'Enable','on')
H = handles.(Field);
String = get(H, 'String');
Value = get(H, 'Value');
fichier = String{Value};
set (handles.graph_1,'String',{'', fichier },'value',1);
end
end
i would like than " fichier " become a variables which can add all the thing i select, These are "String" and if i put " fichier " in this code :
set (handles.graph_1,'String',{'', fichier },'value',1);
All the string will be show ?
Is it possible ?
Thank you
4 Commenti
Risposte (1)
Geoff Hayes
il 7 Ago 2014
Hugo - if you just want to update fichier at each iteration and then add to the list after, then you could do something like this
fichier = {''};
for iIndex = 1:10
Field = sprintf('%s%d', nameList{1},iIndex);
if findobj('Tag',Field,'Enable','on')
H = handles.(Field);
String = get(H, 'String');
Value = get(H, 'Value');
fichier = [fichier ; String{Value}];
end
end
% now update the widget
set (handles.graph_1,'String',fichier,'value',1);
Try the above and see what happens!
4 Commenti
Geoff Hayes
il 8 Ago 2014
Hugo - I'm not really clear on what you want. You state that i would like to set only the String ME_X , and don't put -1. But you have written code to put the -1. Why? Why not use the example I showed in the previous comment
if isempty(find(strcmpi(fishier, String{Value})))
fichier = [fichier ; String{Value}];
end
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!