필터 지우기
필터 지우기

Unrecognized function or variable 'Fid2'.

조회 수: 2 (최근 30일)
MANISH R
MANISH R 2022년 9월 29일
답변: Walter Roberson 2022년 9월 29일
The code works fine for single asterisk but for double asterisk error occurs. I have attached the code and output below.
CODE:
data='Demo 3.TXT';
FID=fopen(data,'rt');
numberoflines = 44;
for i=1:numberoflines
l = fgetl(FID);
if strcmp(l(1),'**')
target = l(2:end);
l = fgetl(FID);
exist Fid2;
if true(ans)
fclose(Fid2);
end
Fid2 = fopen(target,'w');
end
fprintf(Fid2,[l '\n']);
end
close all
__________________________________________________________
Output:
Unrecognized function or variable 'Fid2'.
Error in untitled3 (line 16)
fprintf(Fid2,[l '\n']);

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 29일
l = fgetl(FID);
if strcmp(l(1),'**')
fgetl returns a character vector (except at end of file)
l(1) will be a single character. A single character can never strcmp() to two characters.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by