Error using textscan Not enough input arguments.
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Abderrahim. B
2023년 9월 25일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!