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!