An N by N by N matrix code

2,652 views (last 30 days)
dunphy
dunphy on 11 Nov 2021
Commented: Walter Roberson about 14 hours ago
How do I code for NxNxN matrix using a letter.

Accepted Answer

KSSV
KSSV on 1 Oct 2025 at 0:00
Edited: MathWorks Support Team on 1 Oct 2025 at 13:13
This answer was flagged by DGM
text(0.5,0.5,'D','FontSize',90,'Color','k')
axis off I=frame2im(getframe(gcf));
iwant = imresize(I,[50 50]) ;
imshow(iwant)
  5 Comments
Spaceman
Spaceman on 6 Mar 2024
text adds text to one point, specifying x and y as scalars. i.e. (0.5,0.5)
'D' is what appears in the image.
'Fontsize',90 specifies how large the D will be.
'Color','k' dictates the D will be black.
Walter Roberson
Walter Roberson 3 minutes ago
@KSSV I do not understand how this solution is intended to produce an N x N x N matrix. At most it produces a 50 x 50 x 3 matrix, but 50 x 50 x 3 is very different than 50 x 50 x 50.

Sign in to comment.

More Answers (3)

Walter Roberson
Walter Roberson on 23 Sep 2025 at 4:24
N = 20; %for example
Letter = 'D'; %for example
Array3d = repmat(Letter, N, N, N);

DGM
DGM on 23 Sep 2025 at 19:18
For sake of ridiculousness:
N = double('d'); % using a letter
myarray = zeros(N,N,N); % a NxNxN array
size(myarray)
ans = 1×3
100 100 100
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Yes, I did think about creating a volumetric image of a letter, but I'm lazy today.

Magisha
Magisha about 5 hours ago

imshow(iwant)

  1 Comment
Walter Roberson
Walter Roberson 2 minutes ago
This is the final line from @KSSV answer, and does not make any sense without the previous code posted by KSSV.

Sign in to comment.

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!