Hello,
I am trying to make a runge-kutta code that solves a coupled ode by taking initial values (x0 and y0). Can you please guide me on this

댓글 수: 4

Alan Stevens
Alan Stevens 2020년 9월 19일
What do you expect the results to look like?
Gerard Rojo
Gerard Rojo 2020년 9월 19일
It should look something like this. The values I get are very close to the initial value, when it should be much bigger.
Gerard Rojo
Gerard Rojo 2020년 9월 19일
I forgot to mention i haven't plotted x and y values for all 20 initial conditions. I have only done it for first 10 initial conditions.
I don't have a solution to your main question, but just wanted to point out that you can do all 20 plots with this one line of code:
figure;
plot(x_rk', y_rk','y', 'MarkerSize',5);

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

답변 (1개)

Wan Ji
Wan Ji 2021년 8월 20일
편집: Wan Ji 2021년 8월 20일

0 개 추천

Use arrayfun to obtain your solutions and Plot them!
x0y0 = [20x2] array?
tspan = [0:dt:t_end];
[tsol, xysol] = arrayfun(@(i) ode45(@odefun, tspan, x0y0(i,:)), 1:20, 'uniform', false);
arrayfun(@(i)plot(xysol{i}(:,1), xysol{i}(:,2),'b'), 1:20);

카테고리

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

제품

릴리스

R2019b

태그

질문:

2020년 9월 19일

편집:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by