Borrar filtros
Borrar filtros

Printing results to a file or two screen.

2 visualizaciones (últimos 30 días)
Paris Papadopoulos
Paris Papadopoulos el 29 de Abr. de 2012
I have created a small program to find all combinations of cetain length possible with the four DNA bases (A,T,G,C) and then search inside a sequence to count the occurences of each combination.
I end up with two arrays, one containing the possible combinations and the other integer values of occurences.
For example for all possible triplets we get an array M<64x3 char> and the array C<1x64 double>.
My problem is, I don't know how to print the results in a file with two columns, one containing each combination as a string (for example "AT" or "CG") and the other column containing the appropriate C value (counts, for example "5").
Actually I would like to be able to use this array to print histograms etc.
I would appreciate any help. Thanks in advance.

Respuestas (1)

Pavel Gorodetsky
Pavel Gorodetsky el 15 de Jun. de 2012
i would use the fprintf function. first you have to open a file for writting and then simply loop your data and write each row to the file. the code would look something like this:
fid = fopen('output.txt', 'w');
for ii = size(M,1)
fprintf(fid, '%s %d\r\n', M(ii, :), C(ii) );
end
fclose(fid)

Categorías

Más información sobre Characters and Strings 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!

Translated by