how to write a struct to a .xls or txt file
1 次查看(过去 30 天)
显示 更早的评论
station = struct(...
'name', {'CD2', 'GYA', 'GOM', 'XAN', 'LZH','KMI', 'LSA','MDJ','WMQ','CNS', 'GUL', 'GZH', 'HEF', 'QZH', 'WHN','WZH'},...
'Jingdu',{103.76 ,106.66,103.84,94.81,108.92,102.74,91.10,129.59,87.69,112.59,110.12,113.65,117.17,118.60,114.35,120.40},...
'Weidu',{30.91, 26.46, 36.09, 36.20, 34.03,25.12,29.73,44.62,43.65,28.12,25.12,23.65,31.52,24.94,30.54,27.55});
1.how can i save it into a xls file , and then load it from the xls file?
0 个评论
回答(1 个)
Image Analyst
2014-4-18
编辑:Image Analyst
2014-4-18
Use struct2table() and writetable():
t = struct2table(station)
writetable(t, 'station.xlsx');
5 个评论
Image Analyst
2014-4-18
OK, so you read it in with some unspecified function (probably xlsread) and then you convert the array or cell array into a structure for convenience elsewhere in your program. OK fine. If you then change that structure and want to save it back out in the original form back to your Excel workbook file, you're going to have to either change your original cell array that you read in, or else use struct2table. Then you're going to have to write back that changed variable to the workbook file with xlswrite() or writetable().
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!