Error using textscan Not enough input arguments.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MAT NIZAM UTI
le 25 Sep 2023
Commenté : MAT NIZAM UTI
le 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 commentaires
Réponse acceptée
Abderrahim. B
le 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!