How can i export a data to tab (10 character space) separated text file...

조회 수: 2 (최근 30일)
I have a n*m matrix at matlab and i need to export them to a txt file and it is important to have 2 features:
1- data should be separated by tab(\t)
2- they have to be scientific number with 8 number precision at this format 0.00000000

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 23일
편집: Azzi Abdelmalek 2013년 6월 23일
A=rand(4)
dlmwrite('myfile.txt', A, 'precision', '%.8f','newline', 'pc','delimiter','\t')

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 6월 23일
fmt_item = '%f.8';
delim = '\t';
nl = '\n';
fmt = [repmat( [fmt_item delim], 1, size(YourMatrix,2)-1 ), fmt_item, nl];
fid = fopen('YourOutput.txt', 'wt');
fprintf(fid, fmt, YourMatrix .' );
fclose(fid);
  댓글 수: 2
Masoud Ghanbari
Masoud Ghanbari 2013년 6월 23일
it will write a number before the data to count them... I Do not need this... ???
Masoud Ghanbari
Masoud Ghanbari 2013년 6월 23일
편집: Masoud Ghanbari 2013년 6월 24일
SORRY... SORRY...
you did this correct.. you know there is 00:30 AM at my region and my tiredness caused that i made a mistake.. but your code has not 8 number precision when it is printed to note... is there any problem with notepad?????

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by