How to fill array of zeros with string

60 ビュー (過去 30 日間)
suleiman abdullahi
suleiman abdullahi 2019 年 8 月 18 日
コメント済み: suleiman abdullahi 2019 年 8 月 18 日
Hello,
I have the following code in which i want to fill the preallocated x with strings instead of number, i reason like this
x = zeros(5,1);
for k =1:length(x)
x(k) = {'load'};
end
x
but i get this error >> Conversion to double from cell is not possible.
Error in weather (line 60)
x(k) = {'load'};
Your help is much appreciated.

採用された回答

Bruno Luong
Bruno Luong 2019 年 8 月 18 日
x = cell(5,1);
for k =1:length(x)
x(k) = {'load'};
end
  1 件のコメント
suleiman abdullahi
suleiman abdullahi 2019 年 8 月 18 日
perfect thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by