How to initialize a table column to a character array?
7 ビュー (過去 30 日間)
古いコメントを表示
I have a table "filetext" which is 19343x46. I want to append a colum on the right containing the character array 'MET'. In other words, 19343 rows of the characters 'MET'. How do I do this? I have tried various approaches.
I created a column that is the same height as filetext:
met = [height(filetext),1];
Then I tried populating it with 'MET'
met(1:height(filetext),1) = 'MET';
but I get the error message
"Unable to perform assignment because the size of the left side is 19393-by-1 and the size of the right side is 1-by-3."
If this was a simple zero initialization I could just do:
filler = zeros(height(filetext),1);
but I don't know how to do this for characters.
採用された回答
Voss
2022 年 11 月 30 日
% a table:
filetext = table([1;2;3;4;5;6])
% append a column of all 'MET' on the right:
filetext{:,end+1} = 'MET'
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!