MATLAB高手求教 Error:Function definitions are not permitted at the prompt or in scripts.%% 目标PDE函数function [c,f,s]=pdefun (x,t,u,du)c=[1;1];f=[0.024*du(1);0.17*du(2)];temp=u(1)-u(2);s=[-1;1].*(exp(5.73*temp)-exp(-11.46*temp));%% 边界条
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/06 19:59:53
![MATLAB高手求教 Error:Function definitions are not permitted at the prompt or in scripts.%% 目标PDE函数function [c,f,s]=pdefun (x,t,u,du)c=[1;1];f=[0.024*du(1);0.17*du(2)];temp=u(1)-u(2);s=[-1;1].*(exp(5.73*temp)-exp(-11.46*temp));%% 边界条](/uploads/image/z/7037492-68-2.jpg?t=MATLAB%E9%AB%98%E6%89%8B%E6%B1%82%E6%95%99+Error%3AFunction+definitions+are+not+permitted+at+the+prompt+or+in+scripts.%25%25+%E7%9B%AE%E6%A0%87PDE%E5%87%BD%E6%95%B0function+%5Bc%2Cf%2Cs%5D%3Dpdefun+%28x%2Ct%2Cu%2Cdu%29c%3D%5B1%3B1%5D%3Bf%3D%5B0.024%2Adu%281%29%3B0.17%2Adu%282%29%5D%3Btemp%3Du%281%29-u%282%29%3Bs%3D%5B-1%3B1%5D.%2A%28exp%285.73%2Atemp%29-exp%28-11.46%2Atemp%29%29%3B%25%25+%E8%BE%B9%E7%95%8C%E6%9D%A1)
MATLAB高手求教 Error:Function definitions are not permitted at the prompt or in scripts.%% 目标PDE函数function [c,f,s]=pdefun (x,t,u,du)c=[1;1];f=[0.024*du(1);0.17*du(2)];temp=u(1)-u(2);s=[-1;1].*(exp(5.73*temp)-exp(-11.46*temp));%% 边界条
MATLAB高手求教 Error:Function definitions are not permitted at the prompt or in scripts.
%% 目标PDE函数
function [c,f,s]=pdefun (x,t,u,du)
c=[1;1];
f=[0.024*du(1);0.17*du(2)];
temp=u(1)-u(2);
s=[-1;1].*(exp(5.73*temp)-exp(-11.46*temp));
%% 边界条件函数
function [pa,qa,pb,qb]=pdebc(xa,ua,xb,ub,t)
%a表示下边界,b表示上边界
pa=[0;ua(2)];
clc
x=0:0.05:1;
t=0:0.05:2;
m=0;
sol=pdepe(m,@pdefun,@pdeic,@pdebc,x,t);
figure('numbertitle','off','name','PDE Demo——by Matlabsky')
subplot(211)
surf(x,t,sol(:,:,1))
title('The Solution of u_1')
xlabel('X')
ylabel('T')
zlabel('U')
subplot(212)
surf(x,t,sol(:,:,2))
title('The Solution of u_2')
xlabel('X')
这段偏微分问题的程序有什么问题吗?为什么老是提示我这个错误?
MATLAB高手求教 Error:Function definitions are not permitted at the prompt or in scripts.%% 目标PDE函数function [c,f,s]=pdefun (x,t,u,du)c=[1;1];f=[0.024*du(1);0.17*du(2)];temp=u(1)-u(2);s=[-1;1].*(exp(5.73*temp)-exp(-11.46*temp));%% 边界条
我可以运行,也许你要注意脚本文件与m文件之间的差别,不能直接在命令窗口和直接新建的m文件(脚本文件script)中运行.你要将这个函数命令保存为一M函数文件,保存为文件名与函数名一致,然后再命令窗口输入定义的函数,敲回车就可以运行出结果.