setappdata and getappdata for multiple variables
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Souvik Agasti
le 21 Juil 2017
Modifié(e) : Walter Roberson
le 21 Juil 2017
Hi,
I am trying to write a code like
function function1=givenfunction(variable)
for i=1:length(variable)
setappdata (0,'data_(i)',variable(i))
end
end
The '(i)' after 'data_' puts a number stored in 'i'. In another function, I would like to get the data like
function function2=anotherfunction
for i=1:length(variable)
m(i)=getappdata (0,'data_(i)')
end
end
How should I do it? Please help me.
0 commentaires
Réponse acceptée
Walter Roberson
le 21 Juil 2017
function function1=givenfunction(variable)
for i=1:length(variable)
setappdata(0, sprintf('data_%d', i), variable(i))
end
end
This would not be recommended. You would typically be much more efficient to just store the entire vector and retrieve it all and pull out the parts you want.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Support Package for USB Webcams dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!