Assign all the elements in a row vector to a matrix but couldn't use the reshape function

조회 수: 1 (최근 30일)
Hello, I have a question about assigning the elements now, below is the detail:
I save the value of calculation in a row vector called sub_results and it's dimension is 1x200 double. However, I need to tabulate the result so I want use a matrix called result to save all the elements in sub_results and the dimension of result is 25*8 double.
Because the method of calculation, I have to use every 8 elements in sub_result as different row in result and that is to say I couldn't use the reshape function to construct the matrix result.
I have tried some method like preallocate a zero matrix but still couldn't solve my problem. Hope you can tell me how to handle this situation. Thanks!

채택된 답변

OCDER
OCDER 2017년 9월 10일
편집: OCDER 2017년 9월 10일
sub_results = (1:200);
result = reshape(sub_results, [8 25])'; %Use transpose operator " ' "
result =
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
...

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by