필터 지우기
필터 지우기

Help Simplifying Complex Code

조회 수: 2 (최근 30일)
Gabriela Garcia
Gabriela Garcia 2021년 1월 19일
편집: Gabriela Garcia 2021년 1월 19일
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by