matlab error: defined variable after local function definition

2 visualizaciones (últimos 30 días)
Hriday Talreja
Hriday Talreja el 26 de Sept. de 2021
Respondida: Walter Roberson el 26 de Sept. de 2021
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.

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de Sept. de 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.

Categorías

Más información sobre Variables en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by