The problem may be with this code
function draw_Callback(hObject, eventdata, handles)
filename = get(handles.import,'String');
values = xlsread(filename);
xCol = values(:,1);
yCol = values(:,2);
set(handles.truc,'Visible','on');
plot(handles.truc,xCol,yCol)
Is handles.import the handle to your Import button? And so when you read the string (from it) you are then trying to open a file named "Import"? The import_Callback saves the name of the file to handles.fileName so your above code should be
function draw_Callback(hObject, eventdata, handles)
if isfield(handles, 'fileName')
filename = get(handles.fileName);
values = xlsread(filename);
xCol = values(:,1);
yCol = values(:,2);
set(handles.truc,'Visible','on');
plot(handles.truc,xCol,yCol)
end
As Luna has indicated, make sure that handles.filename includes the full path to your file. You may need to change the import callback code to
[file, path] = uigetfile('*.xlsx');
handles.fileName = fullfile(file, path);
guidata(hObject,handles);
Best Answer