Error in abf2load (line 14) - cmd = sprintf('Abf2Tmp %s',fn); % Not enough input arguments %
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to load an 'abf2' file using following code. But I am getting an error "not enough input arguments" in line 'cmd = sprintf('Abf2Tmp %s',fn)'. Can anyone help me with this?
function [data, metadata] = abf2load(fn) % function [data, metadata]=abf2load(fn) % this will load abf 2.0 files % in order for it to work you must have Abf2Tmp.exe and the dll in your % active directory.
cmd = sprintf('Abf2Tmp %s',fn);
system(cmd);
tmpfname = sprintf('%s.txt',fn);
data = load(tmpfname,'v1');
metaDataFName = sprintf('%s-md.txt',fn);
tabchar = sprintf('\t');
fid = fopen (metaDataFName,'r');
metadata = struct(); %start as an empty struct
while 1
%cycle through all the lines in the file and add all data to the
%metadata struct
tline = fgetl(fid);
if ~ischar(tline), break, end
valOffset = findstr(tline, tabchar);
mdName = tline(1:valOffset-1);
c = mdName(1);
valOffset=[valOffset, size(tline,2)];
for i=1:size(valOffset,2)-1
mdVal = tline(valOffset(i)+1:valOffset(i+1));
if (strcmp(c,'f') || strcmp(c,'n') || strcmp(c,'l') || strcmp(c,'u') || strcmp(c,'b') )
val = str2num(mdVal);
else
val = {mdVal};
end
if (i > 1)
metadata.(mdName) = [metadata.(mdName),val];
else
metadata.(mdName) = val;
end
end
end
fclose(fid);
%clean up
cmd = sprintf('del %s', tmpfname); %command to delete the temp data file
system(cmd);
cmd = sprintf('del %s', metaDataFName); % command to delete the metadata file
system(cmd);
0 commentaires
Réponse acceptée
Jan
le 14 Mar 2017
The problem is the calling command, most likely. How do you call this function? You require
[data, metadata] = abf2load(Str)
with a matching value for the string variable "Str". How do you call this function?
3 commentaires
Jan
le 14 Mar 2017
Modifié(e) : Jan
le 14 Mar 2017
@ishita: While it does not matter, why you call the code, it matters how you do this. Do you provide the needed input argument or do you press the "Run" button of the compiler? In the last case there is no input in general and you would see the mentioned error message.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Low-Level File I/O 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!