save as ascii files

how to i make 2 columns in the text file i get 1 continuous column for variables Vb & pH.
fid = fopen('gc_test.txt', 'wt');
fprintf(fid, '%4.4f\n', Vb, pH);
fclose(fid);

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 4 日
編集済み: Azzi Abdelmalek 2013 年 8 月 4 日

0 投票

fid = fopen('gc_test.txt', 'wt');
fprintf(fid, '%4.4f\n', [Vb;pH]);
fclose(fid);
If you want two columns
Vb=[1;2;3];
pH=[4;5;6];
fid = fopen('gc_test.txt', 'wt');
fprintf(fid, '%4.4f %4.4f\n',[Vb,pH]' );
fclose(fid);

3 件のコメント

harley
harley 2013 年 8 月 4 日
編集済み: Azzi Abdelmalek 2013 年 8 月 4 日
thanks for your time Azzi, tried that but it still only in one row but alternates between each of the array
0.0500 Vb
0.7557 pH
0.1000 Vb
1.0567 pH
0.1500 Vb
1.2329 ph
i would like it to be like this
Vb pH
0.0500 0.7557
regards
harley
harley 2013 年 8 月 4 日
works, thanks very much Azzi.
regards
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 4 日
A={0.0500 0.7557 ;0.1000 1.0567}
header={'Vb' 'pH'}
fid = fopen('gc_test.txt', 'wt');
fprintf(fid,'%s %s\n',header{:})
fprintf(fid, '%4.4f %4.4f\n',A{:} );
fclose(fid);

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by