Here I am again in my series of questions to get from A to Z on my project. Here is my previous questions. I finally understood how to pass the handles between different callbacks. I want now to plot the curves of the selected checkboxes when I press the pushbutton "Plot!".
If If I press it as first thing nothing happens (the callback is still empty, see code below).
If I press it when I actually want to plot, I get the error: (notice that Test-wone-file_1 is my Guide).
Undefined function or variable 'Test_wone_file_1'.Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Test_wone_file_1('PB2_Callback',hObject,eventdata,guidata(hObject))Error while evaluating UIControl Callback.
Do you have any Idea of what could it be? I attach as always the files and the file .TRA if someone wants to try the code.
% --- Executes on button press in PB1.
function PB1_Callback(hObject, eventdata, handles)dname = uigetdir('C:\Users\MDl\Dropbox\epfl\Internship\matlab scripts');if dname == 0 returnelse cd(dname)endF = dir('*.TRA');for i = 1:length(F) names{i,1} = F(i,1).name;end% Create cell 'false' of same length of names
checkboxes = num2cell(false(length(names),1));% Create the two columns for uitable
myData =[checkboxes names];% Set the uitable
columneditable = [true false];columnformat = {'logical', 'char'};set(handles.uitable2,'data', myData,... 'ColumnFormat', columnformat,... 'ColumnEditable', columneditable,... 'CellEditCallback',@fctCB);handles.myData = myData;handles.files = cell(length(F),2);guidata(hObject, handles)endfunction fctCB(hObject,eventdata)handles = guidata(hObject);files = handles.files;myData = handles.myData;if eventdata.NewData == 1 % read the file only if it isn't already there
if isempty(files{eventdata.Indices(1),1}) fName = myData(eventdata.Indices(1),2); fileName = fopen(fName{1,1}, 'r'); C = textscan(fileName, '%s %s %s', 'Delimiter', ';'); % create two subcells in files at the index eventdata containing the force and displacement
for i = 1:length(C{1,1})-17 files{eventdata.Indices(1),1}{i,1} = str2double(C{1,1}{i+17}); files{eventdata.Indices(1),2}{i,1} = str2double(C{1,2}{i+17}); end endelseend% f1 = cell2mat(files{eventdata.Indices(1),1});
% f2 = cell2mat(files{eventdata.Indices(1),2});
% hold all
% plot(f1,f2)
handles.files(eventdata.Indices(1),:) = files(eventdata.Indices(1),:); guidata(hObject, handles); end% --- Executes on button press in PB2.
function PB2_Callback(hObject, eventdata, handles)handles = guidata(hObject);% files = handles.files;
% CB_answer = cell2mat(handles.uitable2.Data(1:end,1));
% cla;
% set(handles.axes1, 'Visible', 'off')
% for i = 1:length(CB_answer)
% if CB_answer(i) == 1
% f1 = cell2mat(files{i,1});
% f2 = cell2mat(files{i,2});
% hold all
% plot(f1,f2)
% else
% end
% end
% set(handles.axes1, 'Visible', 'on')
guidata(hObject, handles);end
Best Answer