check new line

조회 수: 2 (최근 30일)
huda nawaf
huda nawaf 2011년 12월 10일
hi my file: sfdgfhfgjj?? vvnnjkooupfdre
when read file using fopen and fscanf, them convert file into cell array
I found when there is new line this: [1x4 char]
if i want to check it if there in new line using:
if c(i,j)~='\n'
but did not work properly
thanks
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 12월 10일
It's about time you learned some basic principles on how to ask questions after more than 70 question...

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

답변 (1개)

Walter Roberson
Walter Roberson 2011년 12월 10일
Please show the code you are using to open and scan the data. The method to check for end of line will depend on the details of your existing code.
MATLAB as a language does not recognize "escape sequences" such as \n and \t in strings (this is unlike C.) Instead, those sequences are recognized directly by the routines that deal with formatting strings, such as fscanf() and fprintf().
newline is generally coded either as char(10) or as sprintf('\n') but we will need to see what you have already to know whether either of those would be appropriate for your situation.
  댓글 수: 2
huda nawaf
huda nawaf 2011년 12월 11일
hi,
this is code:
k1=1;
for i=1:7000
k=1;
for j=1:???? unknown (length of columns is different)
celcod{i,k}=z(k1:k1+3);%%%each three symols be one cell
k=k+1;
k1=k1+4;
end
end
I need to check new line in the second loop.
this is sample of my file
?RKGRCRE?RFI???QAGQIRIEERCINAFGNRGGARDLRRG
??HGRKC?AMLGRGHIRCINRQDMRGGA
LRQGFRNLIRNIMRQ?HAMEC?PNKRQGEAFCMRDRCRCRCACH
?NIRNCEACII?FLR?A?NRGII
thanks
Walter Roberson
Walter Roberson 2011년 12월 11일
That does not show the code to open or scan the data. I am looking for the fopen() and fscanf() calls and anything else that you do with the file.

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

카테고리

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