how to solve differential equations

Hi everyone,
I want to solve a two-dimensional system of differential equations.

 채택된 답변

Shashank Prasanna
Shashank Prasanna 2013년 1월 20일

0 개 추천

You can start with ODE45, look through the following page for information on how to set up you system:
Scroll down on the page to see how a non-linear oscillator system was set up for ODE45:

댓글 수: 6

Tina
Tina 2013년 1월 20일
Thanks for you reply Benji! In the first example, when I put the code it gives me an error saying "undefined function or variable t". What should I put in for t?
Shashank Prasanna
Shashank Prasanna 2013년 1월 20일
Could you please share the code that gives you the error? If you run the examples according to the instruction in the right order you will not encounter an error.
Tina
Tina 2013년 1월 21일
I am now putting the van der pol equation example in MATLAB help, which is this one:
dydt = odefun(t,y)
function dydt = vdp1(t,y) dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];
It says: Function deifinitions are not permitted in this context.
Shashank Prasanna
Shashank Prasanna 2013년 1월 21일
You cannot use function definitions in the command line. You will have to create the function in the editor and save the .m file with the same name as the function. In this case vdp1.m
Alternatively you can use anonymous functions.
Tina
Tina 2013년 1월 21일
I did it, but still get that error. Can you copy and paste the code and see the error I am getting?
Shashank Prasanna
Shashank Prasanna 2013년 1월 22일
I think I found something online that does what you want: If this doesn't work for you, then please share your code so we can see what is wrong:

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

추가 답변 (0개)

카테고리

Community Treasure Hunt

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

Start Hunting!

Translated by