Save data in excel sheet using pushbutton.
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Guillaume
on 14 Apr 2019
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');
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!