problem in xlsread function

1 view (last 30 days)
rafi abdul
rafi abdul on 27 Mar 2013
Hi i have loaded one excel file of 2 columns and 10 rows into uitable and ploted graph using plot callback.i have saved xls file and when i am trying to check data in excel file using xlsread it is showing 0*0 matrix.how to proceed please help
function plot_Callback(hObject, eventdata, handles)
% hObject handle to plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data=get(handles.uitable1,'data');
x=data(:,1);
y=data(:,2);
plot(x,y)
% --- Executes on button press in save.
function save_Callback(hObject, eventdata, handles)
% hObject handle to save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
data=get(handles.uitable1,'data');
FileName = uiputfile('*.xls','Save as');
xlswrite(FileName,data,'MEISTER');
% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
filename=uigetfile('*.xls')
[handles.data handles.text]= xlsread(filename)
a=handles.data

Answers (1)

Walter Roberson
Walter Roberson on 27 Mar 2013
You need to
set(handles.uitable1, 'data', mat2cell(handles.data))
Also, when you plot,you should use
data = cell2mat(get(handles.uitable1, 'data'));
That is, uitable() take cell array for their data.
  1 Comment
rafi abdul
rafi abdul on 27 Mar 2013
Thanks for reply.i have copied these two lines in my load callback function and when i am calling load callback function it is showing error message like index exceeds max dimension.and in handles.data it is showing 0*0 matrix.how to proceed. thanks rafi

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!