フィルターのクリア

faster way of using fprintf

3 ビュー (過去 30 日間)
Richard
Richard 2012 年 3 月 12 日
If I have a large cell array say 10x26 where the first two columns are strings and the remaining columns are all numbers. Instead of having to write fprintf(1,'%s\t%s\t%f\t... and so on) is there a faster method which involves not having specify all of the fixed point notations.

採用された回答

Jacob Halbrooks
Jacob Halbrooks 2012 年 3 月 12 日
You might try using REPMAT to specify one format for the numeric data that you repeat for the number of numbers you have. For example:
myData = {'a','b',1,2,3,4};
fSpec = repmat('%f\t',1,size(myData,2)-2);
fprintf(1,['%s\t%s\t' fSpec], myData{:})
  1 件のコメント
Oleg Komarov
Oleg Komarov 2012 年 3 月 12 日
You have to add an additional step if you have more than one line of data:
myData = myData.';

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by