put a some small matrix in a big matris
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a problem. I have a big matrix that in each loop I search for some data that satisfy some conditions. The result of "find" will be a small matrix that can vary in size. I want to put this small matrix in a for example 100*100 zeros matrix. so my problem is: suppose at first iteration I have a 3*4 matrix that I want to be placed in the top left corner of the big matrix. I want to keep the small matrix arrangement. I mean I do not want to reshape the small matrix. in the next iteration, I have another small matrix that I want to be placed exactly next to previous small matrix in the big matrix. I want my program to be able to recognize to put for example the small matrix obtained by 5th iteration at next zero row. Could anyone please help me to do that without lots of "for-if"?
댓글 수: 0
채택된 답변
Walter Roberson
2012년 5월 30일
Just keep a running total of the number of rows you have filled so-far, and place the next matrix starting from the next row.
This assumes you always want to place the next underneath the previous. If you want to place as many as possible to the right that fit inside the width, and then move down to the next available row, then the logic would be a little different: in that case the next available row is your starting row plus the maximum number of rows of what you just placed across.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!