How to fix Cell contents assignment to a non-cell array object ERROR?
古いコメントを表示
Hi,
I am trying to create a loop that will output an array of file names so that I can easily import into Excel. The files are distinguished by the last number only.
for i=1:10
filename{i}=sprintf('imagename_%d%s',i,'.jpg'));
end
I keep getting this error though: Cell contents assignment to a non-cell array object.
回答 (1 件)
Sean de Wolski
2014 年 11 月 26 日
Filename must exist as something else (non-cellular) beforehand. It works fine for me:
clearvars
for i=1:10
filename{i}=sprintf('imagename_%d%s',i,'.jpg');
end
3 件のコメント
Mohanlall
2014 年 11 月 26 日
Diah Junaidi
2017 年 5 月 28 日
cool, it works when I place that "clearvars" in beginning of code. Thanks so much. BTW, what's exactly meaning of clearvars???
Walter Roberson
2017 年 5 月 28 日
The difficulty is that you had an existing variable named filename that was not a cell array. You had to either get rid of the variable by clearing it, or you had to make it a cell array such as with
filename = {};
カテゴリ
ヘルプ センター および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!