How to fill array of zeros with string

47 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by