求教关于matlab的问题M=1.5;%mach numbergamma=5/3;Pr=2/3;%upstream states:r1=1.0;u1=1.0;mu1=0.0005;p1=1/gamma/M^2;T1=2*p1/r1;%downstream statesr2=(gamma+1)*M^2/(2+(gamma-1)*M^2)*r1;u2=((gamma-1)/(gamma+1)+2/(gamma+1)/M^2)*u1;p2=(2*gamma/(gamma+1
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/07 18:16:53
求教关于matlab的问题M=1.5;%mach numbergamma=5/3;Pr=2/3;%upstream states:r1=1.0;u1=1.0;mu1=0.0005;p1=1/gamma/M^2;T1=2*p1/r1;%downstream statesr2=(gamma+1)*M^2/(2+(gamma-1)*M^2)*r1;u2=((gamma-1)/(gamma+1)+2/(gamma+1)/M^2)*u1;p2=(2*gamma/(gamma+1
求教关于matlab的问题
M=1.5;%mach number
gamma=5/3;
Pr=2/3;
%upstream states:
r1=1.0;
u1=1.0;
mu1=0.0005;
p1=1/gamma/M^2;
T1=2*p1/r1;
%downstream states
r2=(gamma+1)*M^2/(2+(gamma-1)*M^2)*r1;
u2=((gamma-1)/(gamma+1)+2/(gamma+1)/M^2)*u1;
p2=(2*gamma/(gamma+1)*M^2-(gamma-1)/(gamma+1))*p1;
T2=2*p2/r2;
%conservation:
A=r1*u1;
B=r1*u1^2+p1;
C=(1/2*r1*u1^2+p1/(gamma-1)+p1)*u1;
%ODE solver:
y0=[T2;-u2*(1+eps)];
tspan=[0 0.25];
options=odeset('RelTol',1e-6,'AbsTol',[1e-9 1e-9]);
[t,y]=ode45('Fb,'tspan,y0,options);
x=-t;
T=y(:,1);
u=-y(:,2);
mu=mu*(T/T1).^0.8;
ux=-3/4./mu.*(B-A*u.^2+3/4*A*T-C+B*u);
Tx=4/5*Pr/mu.*(-1/2*A*u.^2+3/4*A*T-C+B*u);
r=A./u;
p=r.*T/2;
%plot T and u:
figure(1)
plot(x,u);
xlabel('x');
ylabel('u');
%output:
out(:,1)=x;
out(:,2)=u;
save u out -ascii;
out(:,1)=x;
out(:,2)=p;
save p out -ascii;
out(:,1)=x;
out(:,2)=r;
save r out -ascii;
out(:,1)=x;
out(:,2)=mu;
save mu out -ascii;
out(:,1)=x;
out(:,2)=ux;
save ux out -ascii;
out(:,1)=x;
out(:,2)=Tx;
save Tx out -ascii;
out(:,1)=x;
out(:,2)=4/3*mu.*ux./(2*p);
save v out -ascii;
out(:,1)=x;
out(:,2)=5/4/Pr*mu.*Tx./p./sqrt(gamma*T/2);
save h out -ascii
function dy=Fb(t,y);
M=1.5;
gamma=5/3;
Pr=2/3;
r1=1.0;
u1=1.0;
mu1=0.0005;
p1=1/gamma/M^2;
T1=2*p1/r1;
A=r1*u1;
B=r1*u1^2+p1;
C=(1/2*r1*u1^2+p1/(gamma-1)+p1)*u1;
mu=mu1*(y(1)/T1)^0.8;
dy[0;0];
dy(1)=4/5*Pr/mu*(1/2*A*y(2)^2-3/4*A*y(1)+C+B*y(2));
dy(2)=3/4/mu*(-B-A*y(2)-1/2*A*y(1)/y(2));
最后显示?Error:File:C:\matlab6.5\work\shock\shock.m Line:27 Column:18
")" expected,"identifier" found.
求教关于matlab的问题M=1.5;%mach numbergamma=5/3;Pr=2/3;%upstream states:r1=1.0;u1=1.0;mu1=0.0005;p1=1/gamma/M^2;T1=2*p1/r1;%downstream statesr2=(gamma+1)*M^2/(2+(gamma-1)*M^2)*r1;u2=((gamma-1)/(gamma+1)+2/(gamma+1)/M^2)*u1;p2=(2*gamma/(gamma+1
编译器说27行18列少了一个“)”
我找到你的27行应该是这个:[t,y]=ode45('Fb,'tspan,y0,options); 已经很久没用matlab了 我没有见过 ode45 是什么函数 但是我感觉你应该写成[t,y]=ode45('Fb',tspan,y0,options);吧 因为我没见过'Fb,'tspan这样传参的 试试看吧