problem of solving the PDE

3 ビュー (過去 30 日間)
suen
suen 2024 年 3 月 20 日
編集済み: VBBV 2024 年 3 月 21 日
i define the function, boundary and initial condition of the heat equation in a standard form ,when i try to plot the solution with x direction, it gives me an error that x =linspace () is not inside any function. Do i need to create a function file for each function in order to put the x range inside?

回答 (1 件)

VBBV
VBBV 2024 年 3 月 20 日
編集済み: VBBV 2024 年 3 月 20 日
Cut all the lines from 1 till 16 and place it after line 26.
Function declarations must be done at the end of the code in your script file (with properly termination using keyword end ... in your case its done correctly)
  5 件のコメント
suen
suen 2024 年 3 月 21 日
thank you so much
VBBV
VBBV 2024 年 3 月 21 日
編集済み: VBBV 2024 年 3 月 21 日
@suen If your code begins with keyword function in line 1 , then by MATLAB convention the file is considered as function file for which it expects inputs and/or outputs. Since the inputs to function are present later part of your code and defined outside the function body, MATLAB throws such error.
Note that each function must end using keyword end except when there is only one function defined inside the script file.
As mentioned by @Torsten its just MATLAB convention.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by