Allocating values in 1d matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
B = p * ones(327,245,2, uint8); can i do it with a loop?
댓글 수: 0
채택된 답변
Image Analyst
2017년 12월 6일
No need for for loops, especially ones that don't work. Simply use ones:
B = p * ones(327,245,2, 'uint8');
댓글 수: 1
Image Analyst
2017년 12월 6일
Try this:
p=uint8(0);
for L = 3 : -1 : 1
for row = 327 : -1 : 1
for col = 245 : -1 : 1
B(row, col, L)=p;
end
end
end
It's a very inefficient way of doing it. I reverse the indexes to try to make it more efficient though. You should NOT want to do it this way.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!