matlab error: defined variable after local function definition
Show older comments
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.
Answers (1)
Walter Roberson
on 26 Sep 2021
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.
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!