I already have a row matrix, how to change it's dimensions to 5x5 for example?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Francisco Boudagh
am 26 Apr. 2021
Kommentiert: Francisco Boudagh
am 26 Apr. 2021
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Apr. 2021
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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

