setappdata and getappdata for multiple variables

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.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Jul. de 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.

Más respuestas (0)

Categorías

Más información sobre MATLAB Support Package for USB Webcams en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Jul. de 2017

Editada:

el 21 de Jul. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by