Good morning,
I'm trying to read in matlab a ".txt" with the following shape
"RechSt.CalculateP_Usage=0¶
RechSt.CalcWithMidTol=0¶
RechSt.ScoringStandard=0¶"
Having a tab key at the end of each line. When I read it with MATLAB it changes to a symbol like � and therefore, when trying to use the saving file in another software, it gives me an error because it doesn't read the symbol � as a tab key (¶).
How could I fix it?
Thanks in advance!
Sergio

댓글 수: 6

Walter Roberson
Walter Roberson 2019년 10월 29일
Can you attach a sample file (using Attach, not copy and paste), and also show how you are doing the reading?
Sergio Vez
Sergio Vez 2019년 10월 29일
I send you the program, the imput file and the output file.
Thanks!
Walter Roberson
Walter Roberson 2019년 10월 29일
Everything looks fine to me on my system. I do not observe any problem.
Try changing
fileID = fopen('OUTPUT.txt','wt');
to
fileID = fopen('OUTPUT.txt', 'wt', 'n', 'ISO-8896-1');
It looks to me as if you are getting some UTF-8 encoding happening.
Sergio Vez
Sergio Vez 2019년 10월 29일
With 8896 it said
Error using fopen
The encoding 'ISO-8896-1' is not valid.
I changed it to ISO-8859-1 but yet not working. It puts a different symbol but not the tab key yet.
Sergio Vez
Sergio Vez 2019년 10월 29일
Could you help me please?

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

 채택된 답변

Shivam Prasad
Shivam Prasad 2019년 11월 5일
편집: Shivam Prasad 2019년 11월 5일

1 개 추천

Hi Sergio,
Check if this works for you.
s=importdata('inp.txt')
filePh = fopen('outp.txt','w');
fprintf(filePh,'%s\n',s{:});
fclose(filePh);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Standard File Formats에 대해 자세히 알아보기

제품

릴리스

R2019b

태그

질문:

2019년 10월 29일

편집:

2019년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by