From: Corey Kelly on 28 May 2010 11:03 I'm creating multiple impoint() objects on an axes in my gui. I would like all of the handles for these objects to be stored in one structure for easy referencing. I've tried using a standard array, [], as well as a cell array, but neither will accept the impoint handles as objects. In both cases I get errors regarding type conversion. Is there a structure which can hold multiple handles? It would also be nice if it can be grown programmatically, but that isn't as important.
From: us on 28 May 2010 11:55 "Corey Kelly" <ckelly01(a)uoguelph.ca> wrote in message <htolvs$7h5$1(a)fred.mathworks.com>... > I'm creating multiple impoint() objects on an axes in my gui. I would like all of the handles for these objects to be stored in one structure for easy referencing. I've tried using a standard array, [], as well as a cell array, but neither will accept the impoint handles as objects. In both cases I get errors regarding type conversion. > Is there a structure which can hold multiple handles? It would also be nice if it can be grown programmatically, but that isn't as important. well... what's wrong with this one of the solutions clear ih; % <- save old stuff(!)... n=3; for i=1:n ih(i)=impoint; end % select a particular IH, eg,... cih=ih(2); us
From: Corey Kelly on 28 May 2010 13:27 "us " <us(a)neurol.unizh.ch> wrote in message <htop1e$j2m$1(a)fred.mathworks.com>... > "Corey Kelly" <ckelly01(a)uoguelph.ca> wrote in message <htolvs$7h5$1(a)fred.mathworks.com>... > > I'm creating multiple impoint() objects on an axes in my gui. I would like all of the handles for these objects to be stored in one structure for easy referencing. I've tried using a standard array, [], as well as a cell array, but neither will accept the impoint handles as objects. In both cases I get errors regarding type conversion. > > Is there a structure which can hold multiple handles? It would also be nice if it can be grown programmatically, but that isn't as important. > > well... what's wrong with this > > one of the solutions > > clear ih; % <- save old stuff(!)... > n=3; > for i=1:n > ih(i)=impoint; > end > % select a particular IH, eg,... > cih=ih(2); > > us I was trying something similar, and I now have this working, but I think it's made me aware of a misunderstanding I'm having. I was initially under the impression that variables (such as ih in this example) don't have to be declared before use in Matlab, but when I started building my GUI, I noticed that any variables I was keeping in my handles structure needed to be declared before use. This has resulted in my assigning default values to every variable in handles at the beginning of my code, just so the variable is available when it is first referenced. After trying something like what you've suggested, I notice that if I clear a variable, eg: clear handles.ih; it is then initialized, and matlab doesn't complain when it's first called. Should I be clearing all variable names I'll be using at the start of my program, or is there some method which needs to be followed for variables stored in handles?
|
Pages: 1 Prev: MATLAB PlC interface Next: Difference between CLEAR & CLEARVARS |