How to export different string and numberic matrix to a file
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuesta aceptada
Jan
el 4 de Nov. de 2011
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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!