Effacer les filtres
Effacer les filtres

Printing results to a file or two screen.

2 vues (au cours des 30 derniers jours)
Paris Papadopoulos
Paris Papadopoulos le 29 Avr 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.

Réponses (1)

Pavel Gorodetsky
Pavel Gorodetsky le 15 Juin 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)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by