problem using fprintf for writing celldata into world.

2 views (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 17 Feb 2014
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

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!