Runge kutta method matlab

1 次查看(过去 30 天)
Gerard Rojo
Gerard Rojo 2020-9-19
编辑: Wan Ji 2021-8-20
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 个评论
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.
the cyclist
the cyclist 2020-9-19
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
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);

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by