problem in xlsread function

1 次查看(过去 30 天)
rafi abdul
rafi abdul 2013-3-27
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

回答(1 个)

Walter Roberson
Walter Roberson 2013-3-27
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 个评论
rafi abdul
rafi abdul 2013-3-27
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

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by