Creating new variable using different row and column chunks from a matrix

조회 수: 1 (최근 30일)
Tanaya Chatterjee
Tanaya Chatterjee 2023년 9월 25일
편집: Fangjun Jiang 2023년 9월 25일
My data (D) is a '29x46 double' matrix.
I want to sort and create six columns variable(Training1_T) usign the different chunks of a data.
For explaination:
I'm using the following code which is error-free but is not generating the output file I desire
Training1_T= D ([1:14,17:21],[15:29,32:36]);
where from the D matrix, I want matlab to pick two chunks of the data. In the first chunk, I want matlab to use the 1-14th rows and the 17-21st column. For the second chunk, i want the 15-29th rows and 32-36th columns. Finally, I want the output file to have 5 columns only where the second chunk starts from the next row in the new output variable (Training1_T).
The current output is a 19x20 double file but I want it to give me 29x5 output
Please Help. Thank you in advance

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2023년 9월 25일
편집: Fangjun Jiang 2023년 9월 25일
D=rand(29,46);
Training1_T= [D(1:14,17:21);D(15:29,32:36)]
Training1_T = 29×5
0.4639 0.6552 0.5909 0.8170 0.5006 0.9003 0.1424 0.8562 0.3617 0.8886 0.5063 0.1177 0.0033 0.2036 0.1707 0.0110 0.9165 0.3567 0.2180 0.9540 0.1185 0.0209 0.5498 0.3251 0.4267 0.7671 0.0287 0.3322 0.9954 0.4837 0.3038 0.5179 0.0249 0.7210 0.9949 0.6572 0.7353 0.0993 0.7551 0.8169 0.3463 0.2117 0.2269 0.3354 0.9094 0.7500 0.9285 0.2980 0.3788 0.9994

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by