When I input my very simple code, i get this:
function dx = lotka_volterra(t, x)
dx = [0; 0];
alpha = 1;
beta = .05;
delta = .02;
gamma = .5;
dx(1) = alpha * x(1) - beta * x(1) * x(2);
dx(2) = delta * x(1) * x(2) - gamma * x(2);
options = odeset('RelTol', 1e-4, 'NonNegative', [1 2]);
[t,x] = ode45('lotka_volterra', [0 20], [10 10], options);
plot(t,x);
??? function dx = lotka_volterra(t, x)
|
Error: Function definitions are not permitted in this context.
Not sure what this means, and I read other posts, but they were not helpful.

 채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 5일

0 개 추천

You must store that code in a file named lotka_volterra.m
You cannot enter a function at the command prompt, or inside a script.

댓글 수: 1

Aditya Patel
Aditya Patel 2012년 5월 5일
thank you, i was using a remote MATLAB, which did not allow me to save m-files. thank you again

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Gamma Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by