フィルターのクリア

How to export different string and numberic matrix to a file

1 回表示 (過去 30 日間)
frewise
frewise 2011 年 11 月 4 日
I wonder how to export string and numberic matrix (listed below) to a file. For example,
A={'cell';'gene';'protein';'DNA';'RNA'};
B={'cycle';'regulation';'structure';'replication';'editing'};
C=[1;2;3;4;5];
>> [A,B]
ans =
'cell' 'cycle'
'gene' 'regulation'
'protein' 'structure'
'DNA' 'replication'
'RNA' 'editing'
Now I want to make things like following format and export it but fails, help! Thanks for your time!
'cell' 'cycle' 1
'gene' 'regulation' 2
'protein' 'structure' 3
'DNA' 'replication' 4
'RNA' 'editing' 5

採用された回答

Jan
Jan 2011 年 11 月 4 日
You did not explain how the file should look like. If you want a binary file to read it later in Matlab, use SAVE. For a text file with tabs as separators:
A = {'cell';'gene';'protein';'DNA';'RNA'};
B = {'cycle';'regulation';'structure';'replication';'editing'};
C = [1;2;3;4;5];
CC = num2cell(C, 2);
Data = transpose(cat(2, A, B, CC));
FID = fopen('FileName.txt', 'w');
if FID == -1, error('Cannot open file'); end
fprintf(FID, '%s\t%s\t%d\t\n', Data{:});
fclose(FID);
If you want something else, explaining the details is required.
  1 件のコメント
frewise
frewise 2011 年 11 月 4 日
Thank you very much!It works well.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenomics and Next Generation Sequencing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by