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?

采纳的回答

Walter Roberson
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 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by