fprintf filename error
1 次查看(过去 30 天)
显示 更早的评论
Im using fprintf to write some data onto text files and using the following code to define the text file:
for i= 1:length(Table1);
filename{i} = fullfile(CorrFile,[Fieldnames{i} '.txt']);
fid{i} = fopen(filename{i},'wt');
end
Can anyone see why this returns an error;
Cell contents assignment to a non-cell array object.
It seems really strange because if I type:
filename = fullfile(CorrFile,[Fieldnames{1} '.txt']);
it works fine, It just doesnt like to store the filenames in cells. How could I make this work?
In addition, I've used the same code for making text files in another script (filename{}) and it worked fine. I don't understand what is going wrong.
0 个评论
回答(1 个)
Dr. Seis
2012-3-9
Is Fieldnames a string? Do:
ischar(Fieldnames)
if you get a 1, then it is not a cellstr and therefore cannot use {}.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!