필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Input undefined in a function describing differential equations

조회 수: 1 (최근 30일)
Ojaswita
Ojaswita 2013년 5월 3일
마감: MATLAB Answer Bot 2021년 8월 20일
I am new at learning how to use the differential equation solvers in MATLAB. I am trying to work out epidemic model differential equations. I got this tutorial online regarding my subject and I tried to use it. The function is given below:
function ypsir =ypsir(t,y)
a = .01;
b = .1;
ypsir(1) =-a*y(1)*y(2);
ypsir(2) = a*y(1)*y(2)-b*y(2);
ypsir(3) = b*y(2);
ypsir = [ypsir(1) ypsir(2) ypsir(3)]';
but when I run it, it keeps on saying input y is undefined. Can someone pls help! Thanks in advance

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 3일
편집: Azzi Abdelmalek 2013년 5월 3일
You can not run a function, you should call it.
Look at ode45
  댓글 수: 2
Ojaswita
Ojaswita 2013년 5월 4일
편집: Azzi Abdelmalek 2013년 5월 4일
Thanks... i am creating another m file that calls this function, and its giving me an error... in the line that i am using to call the function. Again, this is from the same tutorial that i was using...
to = 0;
tf =50;
yo = [99 1 0];
[t y] = ode45('ypsir',[to tf],yo);
plot(t,y(:,1),t,y(:,2),t,y(:,3))
Zhang lu
Zhang lu 2013년 5월 4일
편집: Zhang lu 2013년 5월 4일
do ypsir.m file you called at your matlab current folder, if not ,do it.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by