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 日

1 投票

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 ExchangeEntering 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