Save data in excel sheet using pushbutton.
1 次查看(过去 30 天)
显示 更早的评论
i am using below code at the click of pushbutton. i want to create an excel sheet. which has 2 colums(Frames(1x1 double) & Diameter(1x1 double)) and multiple rows. for this code it will write only 1 row.
% --- Executes on button press in SaveTag.
function SaveTag_Callback(hObject, eventdata, handles)
% hObject handle to SaveTag (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% global Whole_Data
Whole_Data = {'Frames','Diameter'};
framecount=getappdata(handles.UFramesTag,'original');
dia=getappdata(handles.CalculateTag,'Diam');
Data = {framecount, num2str(dia)};
Whole_Dataa = vertcat(Whole_Data, Data);
xlswrite('Diameters.xlsx', Whole_Dataa);
but this is thowing an error. and i dont know what dimensions i have to change to make it work. Error screenshot is below.
0 个评论
回答(1 个)
Guillaume
2019-4-14
The problem is either with framecount or dia. We have no idea what size they are nor what their type is. It's also unclear why you convert dia into a string. Why not write the number directly in excel?
You would probably find it much easier to use modern matlab tools such as writetable instead of xlsread. Your code may be equivalent (no guarantee since as said, we don't know anything about framecount and dia):
framecount=getappdata(handles.UFramesTag,'original');
dia=getappdata(handles.CalculateTag,'Diam');
WholeData = table(framecount, dia, 'VariableNames', {'Frames', 'Diameter'});
writetable(WholeData, 'Diameters.xlsx');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!