我有一个小的MATLAB函数,我试图通过从命令行调用它来运行,如下所示:
???输入参数“x”未定义。
供参考,我的“主要”功能:
function F = dsr(x)
x(1);
x(2);
x(3);
rho=1.2041;
mu=1.81625e-5;
Re=30;
pref=[10,10,10];
leakagearea=[x(1) x(2) x(3)];
for i=1:3;
turb(i)=2^0.5*0.6*leakagearea(1,i)*pref(1,i)^((1-2*0.65)/2);
ftrans=mu*Re*leakagearea(1,i)^0.5;
ptrans=(ftrans/(turb(i)*rho^0.5))^(1/0.65);
lam(i)=mu*ftrans/(rho*ptrans);
end;
input1=[lam(1,1) turb(1,1) 0.65 0.611 10 x(1) 0 0 2 2 2 0];
input2=[lam(1,2) turb(1,2) 0.65 0.611 10 x(2) 0 0 2 2 2 0];
input3=[lam(1,3) turb(1,3) 0.65 0.611 10 x(3) 0 0 2 2 2 0];
airflow=fopen('130109ex1.prj','rt+');
if(airflow==-1);
errordlg('airflow open Error','Error');
end;
for i=1:11614;
fid=fgetl(airflow);
if(strcmp(upper(fid),upper('1 23 plr_leak1 double_door'))==1);
filepositon=ftell(airflow);
break;
end;
sprintf('다시');
end;
fid=fgetl(airflow);
fseek(airflow,1,'cof');
fprintf(airflow,'%6.5e %5.4f %3.2f %4.3f %d %5.4f %d %d %d %d %d %d\n',input1);
fclose(airflow);
airflow=fopen('130109ex1.prj','rt+');
if(airflow==-1);
errordlg('airflow open Error','Error');
end;
for i=1:11614;
fid=fgetl(airflow);
if(strcmp(upper(fid),upper('2 23 plr_leak1 ev_door'))==1);
filepositon=ftell(airflow);
break;
end;
sprintf('다시');
end;
fid=fgetl(airflow);
fseek(airflow,1,'cof');
fprintf(airflow,'%6.5e %6.5f %3.2f %3.2f %d %5.4f %d %d %d %d %d %d\n',input2);
fclose(airflow);
airflow=fopen('130109ex1.prj','rt+');
if(airflow==-1);
errordlg('airflow open Error','Error');
end;
for i=1:11614;
fid=fgetl(airflow);
if(strcmp(upper(fid),upper('7 23 plr_leak1 single_door'))==1);
filepositon=ftell(airflow);
break;
end;
sprintf('다시');
end;
fid=fgetl(airflow);
fseek(airflow,1,'cof');
fprintf(airflow,'%6.5e %6.5f %3.2f %4.3f %d %5.4f %d %d %d %d %d %d\n',input3);
fclose(airflow);
dos('contamx2 130109ex1.prj');
dos('simread_ysm 130109ex1.sim');
output=fopen('130109ex1.lfr','rt');
A=textscan(output, '%s %s %s %s %s %s');
mm=A{1,4};
a0=str2double(mm(84+2,1)); %x1: 1층 외피 (..+2는 왜하는 거지 ?)
a1=str2double(mm(63+2,1)); %x1: 4층 외피
a2=str2double(mm(35+2,1)); %x1: 8층 외피
a3=str2double(mm(7+2,1)); %x1: 12층 외피
b0=-str2double(mm(85+2,1)); %x2: 1층 계단실문
b1=-str2double(mm(64+2,1)); %x2: 4층 계단실문
b2=-str2double(mm(36+2,1)); %x2: 8층 계단실문
b3=-str2double(mm(8+2,1)); %x2: 12층 계단실문
c0=str2double(mm(87+2,1)); %x3: EV문, 1층
c1=str2double(mm(67+2,1)); %x3: EV문, 4층
c2=str2double(mm(39+2,1)); %x3: EV문, 8층
c3=str2double(mm(11+2,1)); %x3: EV문, 12층
fclose(output);
M=[30 46 38 29 21 19 11 8 -4 -28 -49 27]
S=[a0 a1 a2 a3 b0 b1 b2 b3 c0 c1 c2 c3]
F=(M-S)*(M-S)'
xx=[x(1) x(2) x(3)]
fprintf('%10.9f %10.9f %10.9f',xx)
就是这样。请帮忙。我