Help Simplifying Complex Code

1 visualización (últimos 30 días)
Gabriela Garcia
Gabriela Garcia el 19 de En. de 2021
Editada: Gabriela Garcia el 19 de En. de 2021
clear;
M = readmatrix('a51.xlsx','Sheet','Sheet1','Range','B2:H13'); %the number '51' represents a student's ID.
M(8:12,1)=51; %This is the location of sets of three consecutive '1's
M(5,2)=51;
I want to have the code find where there are three consecutive '1's in the columns of the matrix. Above is what we tell the code after finding it myself.
z1=num2cell(M);
ID51={'Open 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={'Sun';[];[];[];[];[];[];[];[];[];[];[];[]};
b51={'Mon';[];[];[];[];[];[];[];[];[];[];[];[]};
c51={'Tues';[];[];[];[];[];[];[];[];[];[];[];[]};
d51={'Wed';[];[];[];[];[];[];[];[];[];[];[];[]};
e51={'Thur';[];[];[];[];[];[];[];[];[];[];[];[]};
f51={'Fri';[];[];[];[];[];[];[];[];[];[];[];[]};
g51={'Sat';[];[];[];[];[];[];[];[];[];[];[];[]};
L51 = table(ID51,a51,b51,c51,d51,e51,f51,g51);
Table1 = table2array(L51);
Table1(1:12,2:8)=z1;
writecell(Table1,'51Library.xlsx','Sheet',1); %creates the excel file for student 1 during the semester
Above is the code we used to create an excel sheet with the weekdays labeling the columns, the times labeling the rows, and a title. Is there any way to condense this? Perhaps readtable ? Our data is saved into a matrix, as you can see above.

Respuestas (0)

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by