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);

채택된 답변

Jan
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
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.
ishita agrawal
ishita agrawal 2017년 3월 15일
I was pressing "RUN" button. I got the point now. Thak you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by