From: jens on 18 Feb 2010 01:43 "jens " <storebonghoved(a)hotmail.com> wrote in message <hlbs5n$55e$1(a)fred.mathworks.com>... > Hello everybody > > I have the matlab code under.My idea is to use the go111 function to update the listbox by using the set function, but it does not seems to work?It is also not enough to change the string in the listbox, but also in some how the choices should fit. Anybody that can come up with an example how to update the contents of the listbox and correct the choices at the same time. > > > function Test() > close all > > f=figure('name','Testing Data',... > 'numbertitle','off',... > 'menubar','none',... > 'color',[0.85, 0.85, 0.85],... > 'units','normalized',... > 'position',[0 0.1 0.95 0.87]); > > col=get(f,'color'); > > stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; > > > > Beer = uicontrol('Style','radiobutton',... > 'units','normalized',... > 'position',[0.30 0.6 0.05 0.05],... > 'backgroundcolor',col,... > 'String','Beer',... > 'callback',@go11,... > 'Value',0); > > function go11(varargin) > stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; > containsBook = cellfun(@(c) any(strfind(c, 'Book')), stringcell); > noBook = stringcell(~containsBook); > end > > > > Book = uicontrol('Style','radiobutton',... > 'units','normalized',... > 'position',[0.30 0.65 0.05 0.05],... > 'backgroundcolor',col,... > 'String','Book',... > 'callback',@go112,... > 'Value',0); > > function go112(varargin) > stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; > containsBeer = cellfun(@(c) any(strfind(c, 'Beer')), stringcell); > noBeer = stringcell(~containsBeer); > end > > > > > hlb=uicontrol('style','listbox',... > 'units','normalized',... > 'position',[0.10 0.6 0.15 0.1],... > 'string',stringcell); > > function go1(varargin) > > choice=get(hlb,'value'); > if choice==1 > figure(2) > x=[1:10] > plot(x,x.^2) > elseif choice==2 > figure(2) > x=[1:10] > plot(x,x.^3) > elseif choice==3 > figure(2) > x=[1:10] > plot(x,x.^4) > elseif choice==4 > figure(2) > x=[1:10] > plot(x,x.^5) > elseif choice==5 > strings=get(hlb,'string'); > strings(1) > end > end > > > > uicontrol('style','pushbutton',... > 'units','normalized',... > 'position',[0.125 0.5 0.10 0.04],... > 'string','Plot ',... > 'backgroundcolor',col,... > 'callback',@go1); > > > > uicontrol('style','pushbutton',... > 'units','normalized',... > 'position',[0.125 0.3 0.10 0.04],... > 'string','Plot2 ',... > 'backgroundcolor',col,... > 'callback',@go111); > > > function go111(varargin) > Books=get(Book,'Value') > Beers=get(Beer,'Value') > > if Books~=0 > % {}=set(hlb,'string') > noBeer=set(hlb,'string') > figure(6) > elseif Beers~=0 > figure(7) > noBook=set(hlb,'string') > > end > end > end > > > > > Best Regards > > Jens Hey Everybody Anybody that can help? Best Regards Jens
From: Jan Simon on 18 Feb 2010 05:15 Dear Jens! Please excuse me, that I am off topic. Jens wrote: > Thanks again for your great effort in trying to help me.I really appreciatie it. I cannot get it to work the way I want with the code you surgested. Therefore I try on more time to describe in steps what I do with the GUI code under: I'm surprised to read this, because I've read this again some days before: http://www.mathworks.com/matlabcentral/newsreader/view_thread/273685#718196 Jens wrote: > Thanks again for your great effort in trying to help me.I really appreciatie > it. I cannot get it to work the way I want with the code you surgested. > Therefore I try on more time to describe in steps what I do with the GUI > code under: ... And in the posts of "Hans" I find surprising coincidences: Jens wrote: > f=figure('name','Testing Data',... > 'numbertitle','off',... > 'menubar','none',... > 'color',[0.85, 0.85, 0.85],... > 'units','normalized',... > 'position',[0 0.1 0.95 0.87]); > ... > 'callback',@go11, > 'callback',@go111); http://www.mathworks.com/matlabcentral/newsreader/view_thread/270795#710195 Hans wrote: > f=figure('name','test',... > 'numbertitle','off',... > 'menubar','none',... > 'color',[0.85, 0.85, 0.85],... > 'units','normalized',... > 'position',[0 0.1 0.95 0.87]); > ... > 'callback',@go99709); So you are working on this for 2 month and changed your name meanwhile? Please do not misunderstand: This is absolutely not a problem! I'm just curious and I am waiting for the appearence of intelligent chat robots here. Please feel encouraged to go on with asking questions about your program - especially (!!!) if you are a chat robot. Kind regards, I hope this is not insulting in any way, Jan
From: jens on 18 Feb 2010 08:27 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hlj3vq$bq1$1(a)fred.mathworks.com>... > Dear Jens! > > Please excuse me, that I am off topic. > > Jens wrote: > > Thanks again for your great effort in trying to help me.I really appreciatie it. I cannot get it to work the way I want with the code you surgested. Therefore I try on more time to describe in steps what I do with the GUI code under: > > I'm surprised to read this, because I've read this again some days before: > http://www.mathworks.com/matlabcentral/newsreader/view_thread/273685#718196 > Jens wrote: > > Thanks again for your great effort in trying to help me.I really appreciatie > > it. I cannot get it to work the way I want with the code you surgested. > > Therefore I try on more time to describe in steps what I do with the GUI > > code under: ... > > And in the posts of "Hans" I find surprising coincidences: > > Jens wrote: > > f=figure('name','Testing Data',... > > 'numbertitle','off',... > > 'menubar','none',... > > 'color',[0.85, 0.85, 0.85],... > > 'units','normalized',... > > 'position',[0 0.1 0.95 0.87]); > > ... > > 'callback',@go11, > > 'callback',@go111); > > http://www.mathworks.com/matlabcentral/newsreader/view_thread/270795#710195 > Hans wrote: > > f=figure('name','test',... > > 'numbertitle','off',... > > 'menubar','none',... > > 'color',[0.85, 0.85, 0.85],... > > 'units','normalized',... > > 'position',[0 0.1 0.95 0.87]); > > ... > > 'callback',@go99709); > > So you are working on this for 2 month and changed your name meanwhile? > Please do not misunderstand: This is absolutely not a problem! I'm just curious and I am waiting for the appearence of intelligent chat robots here. > Please feel encouraged to go on with asking questions about your program - especially (!!!) if you are a chat robot. > > Kind regards, I hope this is not insulting in any way, Jan Dear Jan First I am not a robot and the link you copied with a thread was about textboxes with symboles. Regarding this problem I found a solution with using jlabels with java language. This has absoult nothing todo with the problem with updating a listbox. I ask questions to learn matlab and I appreciate your and the rest of the matlab users effort in helping others. Best Regards Jens
From: Jan Simon on 18 Feb 2010 08:51 Dear Jens! > First I am not a robot. Ok. So I have to wait for another chance to meet an artificial intelligence. My biggest problem is, that it is by definition impossible to distinguish an artificial from a biological intelligence... My attention was just caught by the similarities appearing under different poster names and the repeated occurence of the trademark "Heineken" :-) So comming back to your problem: This is callback does nothing: function go11(varargin) stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; containsBook = cellfun(@(c) any(strfind(c, 'Book')), stringcell); noBook = stringcell(~containsBook); end You compute the update cell string, but you do not insert it as new string. So add something like: function go11(ObjH, EventData) stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; containsBook = cellfun(@(c) any(strfind(c, 'Book')), stringcell); noBook = stringcell(~containsBook); set(ObjH, 'String', noBook); end It would be helpful, if you could break down the problem in smaller parts. Solving a whole program, which does not run, is impossible. Usually, if the problem is split in atoms, this involves the solution already. Good luck, Jan
From: jens on 18 Feb 2010 11:41 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hljgkr$s83$1(a)fred.mathworks.com>... > Dear Jens! > > > First I am not a robot. > > Ok. > So I have to wait for another chance to meet an artificial intelligence. > My biggest problem is, that it is by definition impossible to distinguish an artificial from a biological intelligence... > > My attention was just caught by the similarities appearing under different poster names and the repeated occurence of the trademark "Heineken" :-) > > So comming back to your problem: > > This is callback does nothing: > function go11(varargin) > stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; > containsBook = cellfun(@(c) any(strfind(c, 'Book')), stringcell); > noBook = stringcell(~containsBook); > end > > You compute the update cell string, but you do not insert it as new string. So add something like: > function go11(ObjH, EventData) > stringcell={'M1_Beer_Carlsberg';'M2_Book_Football';'M3_Beer_Heineken';'M4_Beer_Newcastle';'M5_Book_Basketball';'M6_Beer_Slots'}; > containsBook = cellfun(@(c) any(strfind(c, 'Book')), stringcell); > noBook = stringcell(~containsBook); > set(ObjH, 'String', noBook); > end > > It would be helpful, if you could break down the problem in smaller parts. Solving a whole program, which does not run, is impossible. Usually, if the problem is split in atoms, this involves the solution already. > > Good luck, Jan Dear Jan Thanks for the help. If I use your code I do not need the extra pushbutton for updating the listbox. I still have the problem that when I press the radiobutton Beer the listbox shows the 4 strings with beer, but when I press the pushbutton plot it do not plot the right function. 'M3_Beer_Heineken' is number 3 in the cellarray stringcell, but it is plotted as choice 2. Hope you understand. Sorry I am soo bad to explain by problem. Best Regards Jens
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: mex file define a sparse matrix Next: detect mouse input, not in matlab instance |