I want to produce a matrix of strings. Columns are marked as numbers (0 1 2 3 4 ...) and rows as letters (A B C D ...) the matrix shows as: [A0, A1, A2, A3, ...; B0, B1, B2, B3, ...; C0, C1, ....; ....] How should I done it?

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 6 Jul. 2018

0 Stimmen

string(('A':'E')')+(1:5)

3 Kommentare

Nice. Can you get the web team to explain this capability on the website? It's not obvious from the doc and seems like a commonly used feature.
EXAMPLE: Create an Alphabetical Char Array
'a':'z' all a-z lower case
'A':'Z' all A-Z upper case
'A':2:'Z' every other upper case letter
EXAMPLE: Create a String Matrix
string(('a':'z')') + (1:3)
Sean de Wolski
Sean de Wolski am 6 Jul. 2018
Bearbeitet: Sean de Wolski am 6 Jul. 2018
Hi Ocder,
I can, but it would actually sound better and be more likely to be acted on coming from you(!). File a simple tech support enhancement request through the support center or MATLAB desktop with your wishes. Dev/Doc is more likely to listen to customers than pesky application engineers :)
OCDER
OCDER am 6 Jul. 2018
Haha. Sounds fair. I'll go ahead and send in a request.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

OCDER
OCDER am 6 Jul. 2018

0 Stimmen

STR = strings(10, 10);
for r = 1:10
for c = 1:10
STR(r, c) = string(char(('A'+r-1))) + (c-1);
end
end

Kategorien

Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by