class of returns from get() with 1 vs. mutliple handles
Mostrar comentarios más antiguos
Get(h,'parameter') always returns a cell if h contains more than one handle, but if h is a single handle it returns a value of the class of the parameter.
The result is that a special case needs to be written to handle the return if h is of length 1. Is there a way to avoid this so that get always returns a cell even if it is of length one?
Example: >> for i=1:5;h(i)=line(i,i);set(h(i),'userdata',x);end
>> class(get(h,'userdata')) ans = cell
>> class(get(h(i),'userdata')) ans = double
Respuesta aceptada
Más respuestas (2)
Fangjun Jiang
el 7 de Mzo. de 2011
1 voto
I don't have an answer but I want to second your opinion. I found this inconvenient many times. What I usually do is to add a line to process the result.
if ~iscell(answer),answer={answer};end
Peter
el 8 de Mzo. de 2011
0 votos
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!