How to write a set of numbers into a text file using fprintf

1 回表示 (過去 30 日間)
DSP Masters
DSP Masters 2011 年 12 月 5 日
Hi, Please help me in writing a set of numbers into a txt file.. a = [1.4 2.3 3.4 4.5]; fid = fopen('test.txt','wt') fprinf(fid,'%d %d %d %d\n',a);
Thanks & Regards, sowmya,.

採用された回答

Walter Roberson
Walter Roberson 2011 年 12 月 5 日
Your only real problem is that %d format is for printing integers and the values you want to print are not integral. You should be using %f, %e, or %g instead of %g if you want the fractional part printed out. If you do not want the fractional part printed out, then use the format you have now, but pass fix(a) or round(a) instead of a (depending whether you want truncation or rounding)
  4 件のコメント
Jan
Jan 2011 年 12 月 5 日
Again we see, that reading the error message carefully is very helpful. +1
DSP Masters
DSP Masters 2011 年 12 月 6 日
Thank you soooo much
regards
sowmya..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by