Error using textscan Not enough input arguments.
2 views (last 30 days)
Show older comments
MAT NIZAM UTI
on 25 Sep 2023
Commented: MAT NIZAM UTI
on 25 Sep 2023
Hi I am trying to read multiple .asc file to combine it into a single file, but there is error in the coding, which is using the textread.
clc
clear
format short
[oldFileNames,PathName] = uigetfile('*.asc','Select the asc-files', 'MultiSelect','on');
oldFileNames = cellstr(oldFileNames);
c = cell(size(oldFileNames));
for k = 1:length(oldFileNames)
c{k} = textread(fullfile(PathName,oldFileNames{k}));
end
T = vertcat(c{:});
save('202301.asc','T','-ASCII');
the error is
Out of memory.
Error in textread (line 124)
[varargout{1:nlhs}]=dataread('file',varargin{:}); %#ok<REMFF1>
Error in SMOS_nc_combine (line 20)
c{k} = textread(fullfile(PathName,oldFileNames{k}));
But, i tried to change the textread to textscan, also have error. Here is the code
clc
clear
format short
[oldFileNames,PathName] = uigetfile('*.asc','Select the asc-files', 'MultiSelect','on');
oldFileNames = cellstr(oldFileNames);
c = cell(size(oldFileNames));
for k = 1:length(oldFileNames)
c{k} = textscan(fullfile(PathName,oldFileNames{k}));
end
T = vertcat(c{:});
save('202301.asc','T','-ASCII');
%here is the error
%Error using textscan
%Not enough input arguments.
%Error in SMOS_nc_combine (line 20)
%c{k} = textscan(fullfile(PathName,oldFileNames{k}));
0 Comments
Accepted Answer
Abderrahim. B
on 25 Sep 2023
Hi!
An out of memory issue occurs usually when your code operates on large amounts of data or does not use memory efficiently. You can read more here.
You can work around this by using fopen for which you need to specify the encoding scheme and then call textscan. Do not forget to close the file later using fclose.
If you need more help, please share snaps of your files.
Let me know if these options fix the issue.
-Abderrahim
More Answers (0)
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!