Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

can help me with this simple code?

1 visualizzazione (ultimi 30 giorni)
fede
fede il 23 Mar 2016
Chiuso: MATLAB Answer Bot il 20 Ago 2021
I have a list of string (str_1,str_2.......str_n) an a matrix called "A" of string
str_1 str_2
str_1 str_4
... ...
I want to assign for each "str" a number, for example
str_1=1
str_2=2
....
to have the matrix "A":
1 2
1 4
  1 Commento
Jan
Jan il 23 Mar 2016
"A" cannot be a matrix of strings, because this is not valid in Matlab. Do you mean a cell string?

Risposte (2)

Jan
Jan il 23 Mar 2016

Walter Roberson
Walter Roberson il 23 Mar 2016
If you have the Symbolic Toolbox, you can do this:
str = sym('str_%d', [1 n]);
A = [str(1), str(2)
str(1), str(4)];
subs(A, str, [1 2 17 4])
you might even be able to refer to str_1 directly in A; I would need to test that.

Questa domanda è chiusa.

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by