problem in fscanf with reading the data

조회 수: 1 (최근 30일)
Rutika Titre
Rutika Titre 2015년 12월 30일
댓글: Rutika Titre 2015년 12월 31일
I have a text file fidr = fopen('..\source\real_input.txt','r'); and I have used xreali=fscanf(fidr,'%d'); to read it. fidr contains '-1'. My error is Error using fscanf Invalid file identifier. Use fopen to generate a valid file identifier. Error in line xreali=fscanf(fidr,'%d'); Thank you!

채택된 답변

Walter Roberson
Walter Roberson 2015년 12월 30일
The problem is in your fopen(). That filename was not found, or you did not have permission to open the file. You can get more information by using the two-output version of fopen:
[fidr, status] = fopen('..\source\real_input.txt', 'r');
if fidr < 0
fprintf(2, 'fopen failed because %s', status);
end
  댓글 수: 1
Rutika Titre
Rutika Titre 2015년 12월 31일
Hello Sir, Thank u for your answer. I had got its solution it was a very silly mistake I had made. Thank You!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by