I having error in fileID=fopen(filename). Anyone can help with it? thanks

3 次查看(过去 30 天)
function [ rc ] = parseRunCaseFile(filename)
% -fileLen mod done
fileID = fopen(filename);
file = textscan(fileID, '%s', 'delimiter', '\n','whitespace', '');
file=file{1};
i=1;
runcase = 1;
fileLen = length(file);
while i<fileLen
str = char(file{i});
header = regexpi(str, 'Run case');
if(length(header)>0)
%load run case name
a = strtrim(regexpi(str,'Run case \d:', 'split'));
rc(runcase).name = char(a(2));
%Skip remainder of header
i=i+2;
while(length(char(file(i)))>0)
i=i+1;
end
%Read off values
rc(runcase).alpha = findValue(file,'alpha', [i,fileLen]);
rc(runcase).beta = findValue(file,'beta', [i,fileLen]);
rc(runcase).pb2V = findValue(file,'pb/2V', [i,fileLen]);
rc(runcase).qc2V = findValue(file,'qc/2V', [i,fileLen]);
rc(runcase).rb2V = findValue(file,'rb/2V', [i,fileLen]);
rc(runcase).CL = findValue(file,'CL', [i,fileLen]);
rc(runcase).CD0 = findValue(file,'CDo', [i,fileLen]);
rc(runcase).bank = findValue(file,'bank', [i,fileLen]);
rc(runcase).elevation = findValue(file,'elevation', [i,fileLen]);
rc(runcase).heading = findValue(file,'heading', [i,fileLen]);
rc(runcase).Mach = findValue(file,'Mach', [i,fileLen]);
rc(runcase).velocity = findValue(file,'velocity', [i,fileLen]);
rc(runcase).density = findValue(file,'density', [i,fileLen]);
rc(runcase).grav_acc = findValue(file,'grav.acc.', [i,fileLen]);
rc(runcase).turn_rad = findValue(file,'turn_rad.', [i,fileLen]);
rc(runcase).load_fac = findValue(file,'load_fac.', [i,fileLen]);
rc(runcase).X_cg = findValue(file,'X_cg', [i,fileLen]);
rc(runcase).Y_cg = findValue(file,'Y_cg', [i,fileLen]);
rc(runcase).Z_cg = findValue(file,'Z_cg', [i,fileLen]);
rc(runcase).mass = findValue(file,'mass', [i,fileLen]);
rc(runcase).Ixx = findValue(file,'Ixx', [i,fileLen]);
rc(runcase).Iyy = findValue(file,'Iyy', [i,fileLen]);
rc(runcase).Izz = findValue(file,'Izz', [i,fileLen]);
rc(runcase).Ixy = findValue(file,'Ixy', [i,fileLen]);
rc(runcase).Iyz = findValue(file,'Iyz', [i,fileLen]);
rc(runcase).Izx = findValue(file,'Izx', [i,fileLen]);
rc(runcase).visc_CL_a = findValue(file,'visc CL_a', [i,fileLen]);
rc(runcase).visc_CL_u = findValue(file,'visc CL_u', [i,fileLen]);
rc(runcase).visc_CM_a = findValue(file,'visc CM_a', [i,fileLen]);
rc(runcase).visc_CM_u = findValue(file,'visc CM_u', [i,fileLen]);
runcase = runcase+1;
end
i=i+1;
end
fclose(fileID);
end
  5 个评论
Mohammad Yacoob
Mohammad Yacoob 2020-2-14
Below is what the command window shows!
>> parseRunCaseFile
Not enough input arguments.
Error in parseRunCaseFile (line 5)
fileID = fopen(filename);

请先登录,再进行评论。

回答(1 个)

Bhaskar R
Bhaskar R 2020-2-14
编辑:Bhaskar R 2020-2-14
That means your are trying to run function without giving input filename. You should run the function in script file or command window with passing input variable filename as
>> filename = 'give your complete file full path';
>> [ rc ] = parseRunCaseFile(filename)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by