write data to specific column in text file
2 次查看(过去 30 天)
显示 更早的评论
I have this text file created from
I = imread('3.jpg');
i = im2bw(I);
m = max(max(i));
[r c] = find(i == m);
fid = fopen('lalit.txt','wt');
for j=1:length(r)
fprintf(fid,'%f %f\n',r(j),c(j));
end
fclose(fid);
Now i want to do
for m = 1:length(r)
z(m) = round((r(m) + c(m))/2);
end
z=z';
Now i want to save this z as third column in the same text file, but without modifying r and c.
0 个评论
采纳的回答
Walter Roberson
2012-11-20
The only way you should seriously consider for modifying data in text files is to read in the file and write the modified version to another file, possibly followed by renaming the new file to the old name. Modifying a text file "in place" is tricky and often not possible anyhow.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!