Selecting a row of numbers clockwise around a matrix of values

조회 수: 2 (최근 30일)
Aramis
Aramis 2021년 10월 20일
댓글: Image Analyst 2021년 10월 21일
Hi people,
I have an excel file as a matrix of random values (10 rows by 16 columns). I would like to select the value of outer cells, countiniously in clockwise direction (as illustrated in photo starting with cell #1 and ending with cell #17) and paste it as a row of 48 values into a new excel file. My ultimate goal is reading mutiple files in a folder ,and paste the same string row by row in a single excel file.
I appreciate your help and answers for learning and understanding it.

답변 (1개)

Image Analyst
Image Analyst 2021년 10월 20일
mTop = m(1, :);
mLeft = m(2:end, end);
mBottom = fliplr(m(end, 1:end-1));
mRight = flipud(m(2:end-1, 1));
outerValues = [mTop(:); mLeft(:); mBottom(:); mRight(:)]
  댓글 수: 2
Aramis
Aramis 2021년 10월 20일
Thanks for your quick awesome reply. Is there any way to make it a bit expanded to read multiple excel files and make an output for all of them in a single file?
Image Analyst
Image Analyst 2021년 10월 21일
Put that code into a function, and call it inside a loop over the files. See the FAQ:

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by