フィルターのクリア

problem with fprintf for strings

8 ビュー (過去 30 日間)
Jessica jones
Jessica jones 2011 年 11 月 30 日
I am having a problem with fprintf, I am printing a combination of numbers and strings and it works perfectly except for the 4th string which gets the first charater cut off. I assume that this is a formating issue but I cann't figure it out.
fhl = fopen('test1.txt','w');
fprintf(fhl,repmat('%s\t',1,13),vfn{:});
fprintf(fhl,'\n');
fmt = '%s\t%s\t%d\t%s\t%f\t%d\t%d\t%d\t%d\t%s\t%d\t%s\t%d\t%d\n';
fprintf(fhl,fmt,vf{1,:});
fclose(fhl);
Does anyone see my error?
  1 件のコメント
Honglei Chen
Honglei Chen 2011 年 11 月 30 日
What is the first character that gets cut off? Perhaps it's something needs an escape, like a quote or something?

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

採用された回答

Walter Roberson
Walter Roberson 2011 年 11 月 30 日
The 4th string for vfn or vf ? If it is vf then I would want to cross-check class() of the vf{1,:} cells: if you were off by one in your counting then the character would be interpreted by one of your %d or %f formats.
  1 件のコメント
Jessica jones
Jessica jones 2011 年 11 月 30 日
Thanks, I thought I had checked it but I missed one

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by