How do I print out a sequence of numbers on a text file using fprintf??
4 ビュー (過去 30 日間)
古いコメントを表示
Syamsundar Menon Murali Mohan
2021 年 9 月 8 日
コメント済み: Syamsundar Menon Murali Mohan
2021 年 9 月 9 日
%Print values into text file
centx = props.Centroid(1)
centy = props.Centroid(2)
fprintf('imagenumber',centx, centy);
I've already got the values of the centx and centy, and they are generated fine. The only issue is I would like a numbered list for each value of centx and cent y.
e.g.
image number cent x cent y
1 0.1 0.2
2 0.2 0.4
3 0.3 0.6
4 0.4 0.8
etc.
I hope someone can help me with this!
0 件のコメント
回答 (1 件)
KSSV
2021 年 9 月 8 日
fid = fopen('test.txt','w') ;
fprintf(fid,'%s %s %s\n','Imaage Number','centx','centy') ;
n = 10 ;
for i = 1:n
fprintf(fid,'%d %f %f\n',i,rand,rand) ;
end
fclose(fid) ;
10 件のコメント
Walter Roberson
2021 年 9 月 9 日
Under what circumstances is the count restarting? Is it restarting once for each file? Are you doing multiple runs with the same sets of files and appending to the output? Are you doing runs over different directories and appending to the output?
Is it possible that you are detecting multiple regions for each image and wanting to save the centroid for each region? If so then it is not clear to me that the numbering should be continuing through all of the files: how would you determine where each file ended in the list?
For that matter, even if there is only one output per file, how do you make it clear which output line corresponds to which input file?
参考
カテゴリ
Help Center および File Exchange で Text Analytics Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!