Effacer les filtres
Effacer les filtres

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

5 vues (au cours des 30 derniers jours)
Mohammad Yacoob
Mohammad Yacoob le 14 Fév 2020
Modifié(e) : Bhaskar R le 14 Fév 2020
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 commentaires
Bhaskar R
Bhaskar R le 14 Fév 2020
Can you paste complete error?
Mohammad Yacoob
Mohammad Yacoob le 14 Fév 2020
Below is what the command window shows!
>> parseRunCaseFile
Not enough input arguments.
Error in parseRunCaseFile (line 5)
fileID = fopen(filename);

Connectez-vous pour commenter.

Réponses (1)

Bhaskar R
Bhaskar R le 14 Fév 2020
Modifié(e) : Bhaskar R le 14 Fév 2020
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)

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by