How to define numerical variable names in a loop

I have a variable with dimension 44 x 59 which I would like to display in a table. I want the row names to be years from 1979 to 2022, and variable names to be days in January and February (skipping the leap year), in a format of 1/1, 1/2.... ending in 2/28. How do I define the row names and variable names for this particular case?

댓글 수: 4

Why do you want to give a name to each single matrix element ?
Tasi
Tasi 2023년 5월 12일
The values of the array represent January and February values for a period of 1979-2022.
Torsten
Torsten 2023년 5월 12일
편집: Torsten 2023년 5월 12일
And what's the problem if you use M(i,j,k) for the i'th day in the j'th month of the k'th year, e.g. ?
Tasi
Tasi 2023년 5월 12일
I was trying various ways to define them in a loop but unsuccessfully,

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

 채택된 답변

Walter Roberson
Walter Roberson 2023년 5월 12일
jan_names = "1/" + (1:31);
feb_names = "2/" + (1:28);
varnames = [jan_names, feb_names];
rownames = string(1979:1979+size(YourArray,1)-1);
T = array2table(YourArray, 'VariableNames', varnames, 'RowNames', rownames);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2023년 5월 12일

댓글:

2023년 5월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by