unable to store variable in Matlab Gui -


i know several variants of issue have been discussed elsewhere, still unable solve problem. please help.

i have created function part of larger gui, unable store 3 data variables (avex, avey, avez) later use guidata(hobject, handles). doing wrong?

here function:

%call checkbox values = 1:30 checkboxes=get(handles.(sprintf('checkboxav%d',i)),'value') checkboxes(i,1)=checkboxes(1,1); end  plotdata=handles.plotdata;  [row,col] = find(checkboxes==1)   num=length(plotdata{1,1}(:,1)); datay = zeros(num,length(row));%zero matrix  %average y data k=1:length(row)     datay(:,k)=plotdata{row(k,1),col(k,1)}(:,4); end  [m,n] = size(datay) if (n==1)     avey=datay' elseif (n>1)         avey=mean(datay'); end avey=avey';   %average x data kk=1:length(row)     datax(:,kk)=plotdata{row(kk,1),col(kk,1)}(:,1); end  test=datax(:,1); comp=any(bsxfun(@minus,datax,test),1) s = sum(comp)     if (s > 0)             h=msgbox(['note! wavelength index selected samples not identical.'])     end   [c,r] = size(datay) if (r==1)     avex=datax' elseif (r>1)         avex=mean(datax'); end avex=avex';   %average z data kkk=1:length(row)     dataz(:,kkk)=plotdata{row(kkk,1),col(kkk,1)}(:,5); end  [m,n] = size(dataz) if (n==1)     avez=dataz' elseif (n>1)         avez=mean(dataz'); end avez=avez';  handles.aveheader=aveheader handles.avex=avex; handles.avey=avey; handles.avez=avez; guidata(hobject, handles); 

and here error message:

undefined function or variable 'hobject'.  error in cdanalyzer>averageplotfcn (line 5276) guidata(hobject, handles);  error in cdanalyzer>checkboxav1_callback (line 5076) averageplotfcn(handles)  error in gui_mainfcn (line 95)         feval(varargin{:});  error in cdanalyzer (line 17)     gui_mainfcn(gui_state, varargin{:});  error in matlab.graphics.internal.figfile.figfile/read>@(hobject,eventdata)cdanalyzer('checkboxav1_callback',hobject,eventdata,guidata(hobject))  error while evaluating uicontrol callback 

"guidata(object_handle,data) stores variable data object specified object_handle" need specify object_handle. hobject undefined in local function.

use gcbo instead, "returns handle of graphics object callback executing":

guidata(hobject, handles); 

becomes

guidata(gcbo, handles); 

alternatively, add hobject input function averageplotfcn. so:

function averageplotfcn(hobject,~) ... end 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -