using loops in fprintf to print a large number of columns

1 回表示 (過去 30 日間)
Peter McColgan
Peter McColgan 2018 年 11 月 9 日
回答済み: KSSV 2018 年 11 月 9 日
Dear all,
I have tried the following to print out a table where the first column is a string and the remaining columns are numbers. How can i do this using a loop (this is needed as I have 50 columns);
I need to loop through j in num(i,j)
%print out results
fid1 = fopen(fullfile('test.csv'),'w');
for i=1:length(gene)
fprintf(fid1,'%s, %d, %d\n', string{i}, num(i,1), num(i,2));
end
fclose(fid1);

回答 (1 件)

KSSV
KSSV 2018 年 11 月 9 日
If it a table use: writetable. Also have a look on xlswrite.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by