how to write a table 1*4 which is inside a for loop into excel?
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have a table S of size 1*4 inside a for loop which iterates 45 times. I want to store the values in the table for each iteration in an excel sheet.I want the values stored in a new row as the loop iterates, yet i dont want the table heading for every iteration. To sum it up, i want the table heading in the first row of the excel sheet and the values of each iteration in the subsequent rows. So far i have this can someone please help me with this code? what am i doing wrong? what should i have done?
for ii=1:c3
e1= graycoprops(g1);
S=struct2table(e1); % 1*4 table
tableHeaders = {'Contrast','Correlation','Energy','Homogeneity' }; %header for the table
filename = 'laws1.xlsx';
sheet = 1;
xlRange = 'A1';
xlswrite(filename, tableHeaders, sheet, xlRange); %writing table headers into excel sheet
mainArrayToWrite = [S.Contrast.', S.Correlation', S.Energy.', S.Homogeneity.']; %table values
filename = 'laws1.xlsx';
sheet = 1;
x1Range='A2';
xlswrite(filename, mainArrayToWrite, sheet, xlRange); %writng the table values into excel sheet
end
Thankyou in advance.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!