An N by N by N matrix code
2.792 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
dunphy
am 11 Nov. 2021
Kommentiert: Walter Roberson
vor etwa 12 Stunden
How do I code for NxNxN matrix using a letter.
0 Kommentare
Akzeptierte Antwort
KSSV
am 1 Okt. 2025 um 0:00
Bearbeitet: MathWorks Support Team
am 1 Okt. 2025 um 13:13
Diese(r) Antwort wurde durch DGM
markiert
text(0.5,0.5,'D','FontSize',90,'Color','k')
axis off I=frame2im(getframe(gcf));
iwant = imresize(I,[50 50]) ;
imshow(iwant)
5 Kommentare
Spaceman
am 6 Mär. 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
vor 28 Minuten
@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.
Weitere Antworten (3)
Walter Roberson
am 23 Sep. 2025 um 4:24
N = 20; %for example
Letter = 'D'; %for example
Array3d = repmat(Letter, N, N, N);
0 Kommentare
DGM
am 23 Sep. 2025 um 19:18
For sake of ridiculousness:
N = double('d'); % using a letter
myarray = zeros(N,N,N); % a NxNxN array
size(myarray)
Yes, I did think about creating a volumetric image of a letter, but I'm lazy today.
0 Kommentare
Magisha
vor etwa 5 Stunden
imshow(iwant)
1 Kommentar
Walter Roberson
vor 31 Minuten
This is the final line from @KSSV answer, and does not make any sense without the previous code posted by KSSV.
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!