Help with Dataread and textread error

8 views (last 30 days)
Monika Chaulagain
Monika Chaulagain on 15 Jul 2020
Commented: dpb on 16 Jul 2020
I'm a beginner with matlab and i'm trying to do power spectrum analysis with a txt file and this is the error that i'm receiving, please help me understand it.
Error using dataread
Trouble reading integer from file (row 21620, field 1) ==>
Error in textread (line 171)
[varargout{1:nlhs}]=dataread('file',varargin{:}); %#ok<REMFF1>
Error in ReadSpectraVSplots (line 46)
=
textread(fnameFFT,'%d%s%s%s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f',numrow,'headerlines',numskip);
>>
  6 Comments
Walter Roberson
Walter Roberson on 16 Jul 2020
I would suspect you have an off-by-one error in calculating numrow, or alternately that your numskip is one too large.
dpb
dpb on 16 Jul 2020
Again, if want somebody to fix the format string and/or show specifics for textscan or another non-deprecated function to replace textread, attach (a section of) the data file so can see what's actually there.
It's probably too large to do whole thing as text, just select first/last pages in editor and paste them into another file would be more than enough...

Sign in to comment.

Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!