Error in abf2load (line 14) - cmd = sprintf('Abf2Tmp %s',fn); % Not enough input arguments %
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jan
2017년 3월 14일
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
Jan
2017년 3월 14일
편집: Jan
2017년 3월 14일
@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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Low-Level File I/O에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!