Making matrix with letters

13 次查看(过去 30 天)
dunphy
dunphy 2021-11-13
编辑: Voss 2021-12-29
How do I make NxN matrix using letter? This matrix should also be viewed in image.
  1 个评论
Jan
Jan 2021-11-13
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?

请先登录,再进行评论。

回答(1 个)

Voss
Voss 2021-12-29
编辑:Voss 2021-12-29
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' 'BICQFPHOKPGFBNGYFQJWFKUXIXFJJIFNSJSWMWREVNXGDENBDM' 'LRJKFVRT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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');

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by