How to correct this?

조회 수: 2 (최근 30일)
Kyle Saylon
Kyle Saylon 2018년 6월 4일
댓글: Greg 2018년 6월 4일
tspan = [55. 121.]; % Range for the independent variable
y0 = [467.992; 0.0423866]; % Initial values for the dependent variables
function dYfuncvecdt = ODEfun(t,Yfuncvec);
T = Yfuncvec(1);
X = Yfuncvec(2);
NCp = 2504;
V = 3.265 + 1.854;
Nao = 9.0448;
UA = 35.83;
dH = -590000;
Nbo = 33;
k = 0.00017 * exp(11273 / 1.987 * (1 / 461 - (1 / T)));
Qr = UA * (T - 298);
Theata = Nbo / Nao;
ra = 0 - (k * Nao ^ 2 * (1 - X) * (Theata - (2 * X)) / (V ^ 2));
rate = 0 - ra;
Qg = ra * V * dH;
dTdt = (Qg - Qr) / NCp;
dXdt = (0 - ra) * V / Nao;
dYfuncvecdt = [dTdt; dXdt];
function dYfuncvecdt = ODEfun(t,Yfuncvec);
Error: Function definitions are not permitted in this context.
  댓글 수: 1
Kyle Saylon
Kyle Saylon 2018년 6월 4일
I exported this solution from polymath. They said that it can be copied directly after exporting.

댓글을 달려면 로그인하십시오.

답변 (1개)

Greg
Greg 2018년 6월 4일
편집: Greg 2018년 6월 4일
If the first non-comment line is not a function declaration (or a few other options such as classdef), the file is a script. Embedding functions in scripts was introduced in R2016b.
  • If you're running pre-R2016b, you can't do it, period.
  • If you're running R2016b or newer, you have to close each function with an end.
  댓글 수: 3
Kyle Saylon
Kyle Saylon 2018년 6월 4일
I'm running R2017a. I just exported this from polymath and they said that the code can be copied directly to the matlab editor.
Greg
Greg 2018년 6월 4일
No idea what polymath is, but I rarely find they said… to be reliable.
As Aakash asked, what exactly are you trying to do? Can you link to or upload this polymath reference?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by