How to assign a column of text string to another variable?
古いコメントを表示
For example,
A = repmat('test', 5,1);
If I want to assign A to B, why the below doesn't work? What is the right way to do it?
B([20+1:20+5,1) = A
Many thanks,
6 件のコメント
Adam Danz
2020 年 3 月 9 日
What is B? A char array? A string array? A cell array?
Adam Danz
2020 年 3 月 9 日
You can use class(var) to determine the class of a variable var.
Yes, it's problematic. Your definition of B creates a double precision numeric vector. But A is a char array.
Perhaps you're looking for
% Cell array of chars
A = repmat({'test'}, 5,1);
B = cell(100000,1);
B([20+1:20+5]) = A;
or
% String array
A = repmat("test", 5,1);
B = repmat("", 100000,1)
B([20+1:20+5]) = A;
Leon
2020 年 3 月 9 日
Leon
2020 年 3 月 9 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!