how to write a table 1*4 which is inside a for loop into excel?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!