Printing results to a file or two screen.
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Pavel Gorodetsky
2012-6-15
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)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!