An N by N by N matrix code

852 次查看(过去 30 天)
dunphy
dunphy 2021-11-11
编辑: MathWorks Support Team 2025-10-7,12:39
How do I code for N x N x N matrix using a letter.

采纳的回答

KSSV
KSSV 2025-10-7,0:00
编辑:MathWorks Support Team 2025-10-7,12:39
text(0.5,0.5,'D','FontSize',90,'Color','k')
axis off
I=frame2im(getframe(gcf));
iwant = imresize(I,[50 50]) ;
imshow(iwant)
  5 个评论
Spaceman
Spaceman 2024-3-6
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 2025-10-2,16:54
@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.

请先登录,再进行评论。

更多回答(3 个)

Walter Roberson
Walter Roberson 2025-9-23
N = 20; %for example
Letter = 'D'; %for example
Array3d = repmat(Letter, N, N, N);

DGM
DGM 2025-9-23
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 2025-10-2,11:58

imshow(iwant)

  1 个评论
Walter Roberson
Walter Roberson 2025-10-2,16:52
This is the final line from @KSSV answer, and does not make any sense without the previous code posted by KSSV.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by