Creating a Table with rows labeled from a matrix and exporting it into an excel file
Show older comments
My code is combersome and complicated. I want to read the matrix and its specific values (as indicated in lines 3 and 4) then convert it into a table with labels. I want the columns to be labeled the days of the week, starting with Sunday, and the rows labeled times from 9:00am to 8:00pm. Once I have that table created, I want to export it into an excel file. I would like the new excel file to open when I run the script, but that is not a dire necessity. Please help and explain if you can. I really appreciate it!
clear;
M51 = readmatrix('a51.xlsx','Sheet','Sheet1','Range','B2:H13');
M51(8:12,1)=51;
M51(5,2)=51;
z51=num2cell(M51);
time51={'hours';'9:00';'10:00';'11:00';'12 noon';'1:00 p.m.';'2:00';'3:00';'4:00';'5:00';'6:00';'7:00';'8:00'};
a51={'Sunday';[];[];[];[];[];[];[];[];[];[];[];[]};
b51={'Monday';[];[];[];[];[];[];[];[];[];[];[];[]};
c51={'Tuesday';[];[];[];[];[];[];[];[];[];[];[];[]};
d51={'Wednesday';[];[];[];[];[];[];[];[];[];[];[];[]};
e51={'Thursday';[];[];[];[];[];[];[];[];[];[];[];[]};
f51={'Friday';[];[];[];[];[];[];[];[];[];[];[];[]};
g51={'Saturday';[];[];[];[];[];[];[];[];[];[];[];[]};
K51 = table(time51,a51,b51,c51,d51,e51,f51,g51);
Table51 = table2array(K51);
Table51(1:12,2:8)=z51;
writecell(Table51,'51Library.xlsx','Sheet',1); %creates the excel file for student 1 during the semester
Accepted Answer
More Answers (0)
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!