matlab error: defined variable after local function definition
显示 更早的评论
Hi all, I am receiving an error message that I am unsure why it is occurring. The program believes my variables defined outside of a function are used in the function itself. Does anyone have an idea on how to fix this? I have tried moving them to different lines and it still fails. Ill attach the code and the error here. This error always occurs on the first line of code after the last function call.
error: Function definitions in a script must appear at the end of the file. Move all statements after the "pdex1bc" function definition to before the first local function definition.
回答(1 个)
Walter Roberson
2021-9-26
You have to move the lines
x = linspace(0,500,1);
T = linspace(0,500,1);
m=0;
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,T);
to before the first function definition.
类别
在 帮助中心 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!