Unable to read data from text file in matlab
조회 수: 5 (최근 30일)
이전 댓글 표시
clc;
clear all;
close all;
fid = fopen('eeg.txt');
A = fscanf(fid,'%f');
fclose(fid);
when I am trying for run the code I got the following error:
Error using fscanf
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in eeg (line 5)
A = fscanf(fid,'%d');
Kindly help me to get rid of this issue.
댓글 수: 1
답변 (1개)
Bora Eryilmaz
2023년 1월 12일
편집: Bora Eryilmaz
2023년 1월 12일
The file your are looking for is probably not there, or at least, not on the MATLAB path. See what fid is: if it is -1, then you haven't really opened the file, which would result in the error that you are observing:
fid = fopen('badfile.txt')
fscanf(fid, '%f')
To double check if the file is accessible by MATLAB, run:
exist('eeg.txt', 'file')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!