フィルターのクリア

Exporting matrices as text file

1 回表示 (過去 30 日間)
Olu adroit
Olu adroit 2015 年 2 月 4 日
編集済み: dpb 2015 年 2 月 5 日
Hi all, I have three matrices A = [ ‘Picked’], B = [‘P’] and C = [100]. I would like to export them as a single text file (.txt) which will look like this: Picked, P, 100 I have tried to use ‘csvwrite’ but I could only obtain P,i,c,k,e,d,P,100. Please could anyone help me with how to do this. Thanks in advance.
Adroit

採用された回答

dpb
dpb 2015 年 2 月 4 日
編集済み: dpb 2015 年 2 月 5 日
>> fprintf('%s,%s,%d\n',A,B,C)
Picked,P,100
>>
fid=fopen('yourfile','w');
fprintf('%s,%s,%d\n',A,B,C)
fid=fclose(fid);
Character strings are arrays of characters in Matlab so csvwrite treats each character as an array element (as you discovered). Use the string format specifier to put the array out as a single string as shown.
  1 件のコメント
Olu adroit
Olu adroit 2015 年 2 月 4 日
thanks dpb

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

その他の回答 (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