problem in xlsread function
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!