Info
この質問は閉じられています。 編集または回答するには再度開いてください。
can help me with this simple code?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Jan
2016 年 3 月 23 日
"A" cannot be a matrix of strings, because this is not valid in Matlab. Do you mean a cell string?
回答 (2 件)
Jan
2016 年 3 月 23 日
Don't do this!
You find hundrets of concerning threads in this forum, e.g. http://www.mathworks.com/matlabcentral/answers/269836-hi-i-want-to-define-repetitive-vectors-from-notepad-data-using-loop
0 件のコメント
Walter Roberson
2016 年 3 月 23 日
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.
0 件のコメント
この質問は閉じられています。
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!