Unable to read data from text file in matlab
1 次查看(过去 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!