problem using fprintf for writing celldata into world.
1 次查看(过去 30 天)
显示 更早的评论
v =
[ 1] [ 0.005414061590159] [-0.089918561343438]
'p2' [-0.055125605058493] [ 0.077283840482778]
'p3' [ 0.041872392912978] [ 0.048029359618340]
%class is cell
%I perform to write v into ms word like that,
for k=1:size(v,1)
fprintf(fileID, '%3s %40f %3f \n', v{k,:});
end
%It cannot write "1" into world. (others appears) How can I write v with full of first column?
0 个评论
采纳的回答
Walter Roberson
2014-2-17
for k=1:size(v,1)
if ischar(v{k,1})
fprintf(fileID, '%3s %40f %3f \n', v{k,:});
else
fprintf(fileID, '%3d %40f %3f \n', v{k,:});
end
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String Parsing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!