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에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!