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
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에 대해 자세히 알아보기

질문:

2021년 9월 26일

답변:

2021년 9월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by