How to fill just such successive elements in row of matrix?
조회 수: 8 (최근 30일)
이전 댓글 표시
Hello!
i have matrix A (733*3600) randomly generated containing such values,i have a condition , if the value of element (i,j)=k, i want to fill another matrix B starting from element(i,j) until another specific element with a condition to not exceed array bounds.
for example i have k=50
in matrix B , i will fill 500 succesive elements starting from element with value k=50 in matrix A.
for the succesive elements , i want to stop until the limit of number of columns.
i already have a code to not exceed array bounds in this link https://www.mathworks.com/matlabcentral/answers/1799345-how-to-put-condition-in-rows-and-columns-for-not-exceed-array-bounds?s_tid=srchtitle , i tried to fill elements one by one ,but it is hard to apply it now with number of columns so large.
i hope that you could help me!
thanks
댓글 수: 2
dpb
2022년 10월 1일
"to fill another matrix B starting from element(i,j) until another specific element "
What about multiple locations match in a given row? Take first, last, all matches and start from there or what???
채택된 답변
추가 답변 (2개)
Walter Roberson
2022년 9월 30일
Consider for example,
A(i : min(i+k-1, end), j)
This would refer to at most k consecutive rows starting at row i but would stop at the array boundary.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!