필터 지우기
필터 지우기

Printing results to a file or two screen.

조회 수: 2 (최근 30일)
Paris Papadopoulos
Paris Papadopoulos 2012년 4월 29일
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.

답변 (1개)

Pavel Gorodetsky
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)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by