I already have a row matrix, how to change it's dimensions to 5x5 for example?
조회 수: 2 (최근 30일)
이전 댓글 표시
So this is how it is right now. My matrix A = num(idx) is a row matrix. How can I change it's dimensions to 5x5?

댓글 수: 2
채택된 답변
Walter Roberson
2021년 4월 26일
It looks like you are not being asked to draw the primes between 1 and 100; it looks like you are asked to draw the first 100 primes.
num = 1:600;
idx = isprime(num);
A = num(idx);
if length(A) > 100; A = A(1:100); end
A = reshape(A, 10, 10);
imagesc(A)
colorbar
axis equal tight;
A(end)
However, there is a completely different possibility:
num = reshape(1 : 100, 10, 10);
idx = isprime(num);
imagesc(idx)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

