How do I get an element from a string?
古いコメントを表示
Say I have a vector representing a row and column which is (5,6) and I have a
vec = (5,6);
string = ['oNTitsr
reaqBtr
sggtalu
imnvomo
nresgLm
eamhomt
lfHoan
sn mnin']
When I do
a = string(vec);
I get a = 'ne'
and when I do
a = string(5,6);
a = 'L'
I am suppose to get 'L' but I keep getting 'ne' when I run my code.
vec = (5,6) is just an example it can be anything. How do I do it?
2 件のコメント
Andrew Newell
2015 年 2 月 21 日
Is that really the code you used? It should produce errors right from the start. The line
vec = (5,6);
results in
Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
The string definition you used gives
Error: String is not terminated properly.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!