Making matrix with letters

16 visualizzazioni (ultimi 30 giorni)
dunphy
dunphy il 13 Nov 2021
Modificato: Voss il 29 Dic 2021
How do I make NxN matrix using letter? This matrix should also be viewed in image.
  1 Commento
Jan
Jan il 13 Nov 2021
The question is not clear. What does "using letter" mean? Do you want a char matrix?
A = ['ab'; 'cd']
What does "viewed as image" mean?

Accedi per commentare.

Risposte (1)

Voss
Voss il 29 Dic 2021
Modificato: Voss il 29 Dic 2021
N = 50;
A = char(65+floor(26*rand(N)))
A = 50×50 char array
'TTCUQXGZXMDDTWBGCOVXSZQLFDPEGMOYCWLVJDBBNLVWNKBVOV' 'XFMWXJWDIPRZFCTVWUNQCZNTCAPMEKDDAONDDJSGZAFMAXHYZT' 'XDNMBNYKUTUPDZGUDVYUTZOCAMEEDWPLPSDWHLHXBEYZQMOCEE' 'SQFTJDWXXTNKBRINWFRWOVIYVGRVBKODXFXZLXTAKRSFKRCMRR' 'HRYLZSSVXXAXVWSLAXNQOVBZGXGDMKYSTNANJHMDUKORLSAZQV' 'ZGUKRODPJVZICKOYTLEMKBATUKYOQTYEWMHCPHNQPNTHCHVNWL' 'TXEFYREDGQZCHPLABDRJUEWSLOAQNPHMAOXFSGMKOPFSVDGAGL' 'TUNVIGBNZXLBKYZJOHHVSMLZVZZRVAEWAEBHEWJRNZTIFWWHRV' 'QBGXRTMMCVKIARTXWUDDHWAVRVVHLTYELKNVEGXZDZENBUYDXC' 'LRKZJBZXBREABTYRUHZXUYEUCITTRURXYWYKEETNPJUPTSRFMF' 'WPAKELAHZBEFBOUATIQAGUEPRQVYSWMMOQSJUQKBRKVKTRMSWV' 'WAQMBUVQMQZKTKFBUFVHDXLXJZPGCQOUCEAMBZOOJFRAWWDAMF' 'EOLSWMJSCUJEVIUTYTWYPIDFJEIYFPSDGIQSSGCPFBLMAQESTU' 'MEPDNIJQUUJZHNJJXZURNAXTYLLWYLNPLAFAQUOMLYWDWSLMLK' 'BICQFPHOKPGFBNGYFQJWFKUXIXFJJIFNSJSW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JVQTKMILIYYJMRFGIOZGX' 'QCDSSIHAENCZFWQHJAJBEAETTHIFDZYCFBDCJLTXMTMCIBLLCF' 'DQONDQBISKIRZNNBPXGXDTYLYOWGABFLRCMYFEPDFUGECFSBJR' 'PHXMOLLYQCTHHWOKJISDNLTKEQMIRXTMGIVFIOXDRXSXYDZOII' 'DOSQXNYAUEXAFNODFZVIBMCKYZEXWWUMDTRQDAYHDJUYRYOPBS' 'XVUEIPQEPRPETYISVRMEIPJOBAUPPTSEYNZMCPVXALTSQRTGLZ' 'KMBMYXYJIJJNXMMXCVRJKEHXIVCPVOQBLYGPQVBVRESLWNPELB' 'XQADIZVCUABBYGFKQLIQYQQDJASNMCIKEPONLPKSVNIJBLXHJM' 'RWAXKDUBCEECXMCGYJJTECJZFDXCPQSRVGDTHGIFQPFOPEPCVM' 'ZVBOTABWKYNMRPSQVGFIIEXUOBACEESLPIEZFMLDZBOTDYKQWX' 'SYAIAJFQQCJWKJBLWEUDAZIYCHKNJSSMCZEKWTHLSCHFLLMMTB' 'HNPUKZWNZQGAOQVJKWARDYNDYSTUIMCDXNNNUCRIUXPFTOKDYA' 'ENFIQIELWBXJQSPSJHORWMLTFSHTQDIJAZFBNINERBGEQHMVZO' 'UWFWXSZAYNSEZGDXHHBBAUOLMIWINTKEBZLWWXWDKXRSURSDER' 'URLIEJEPUMZWNXOVTARKZKZFKJEUUDGCJZSKCIUUWCSZRWREIY' 'DISNAYHZASLQKRYPPFYYUVHEZGWTGIABQOUCZDKDBXZFNWLOWA'
figure();
[X,Y] = meshgrid(1:N,1:N);
text(X(:),Y(:),num2cell(A),'FontSize',6);
set(gca(),'XLim',[0 N+1],'YLim',[0 N+1],'YDir','reverse','Visible','off');

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by