I have tried Runge Kutta method on this coupled nonlinear ode and get the error respect to the matrix dimension. Please help me with this.

1 vue (au cours des 30 derniers jours)
% Define spatial domain
Ly = 2; % Length of domain
Lz = 1;
N = 200; % Number of discretization points
M = 200;
dy = Ly/N;
dz = Lz/M;
y = -1; % Define x domain % for fixed values of y
z = 0:dz:Lz;
[Y,Z] = meshgrid(y,z);
% Define discrete wavenumbers
eta = (2*pi/Ly)*[-N/2:N/2];
eta = fftshift(eta'); % Re-order fft wavenumbers
jeta = (2*pi/Lz)*[-M/2:M/2];
jeta = fftshift(jeta'); % Re-order fft wavenumbers
[Eta,Jeta] = meshgrid(eta,jeta);
%% Time domain %%
t(1) = 0; dt = 0.05; tf = 10; L = ceil(tf/dt)+1;
dt = 0.0050
tsol = 0
%% function handle %%
f = @(t,F,G) (-g1.*J-F.*((F).*(2.*pi.*1i.*jeta))-((nu+nu_t).*(jeta.^2+eta.^2).*4.*pi.^2)-(nu_t.*4.*pi.^2.*jeta.*eta)-(G.*2.*pi.*1i.*eta));
g = @(t,F,G) (-g1.*J.*P-G.*((G).*(2.*pi.*1i.*eta))-((nu+nu_t).*(jeta.^2+eta.^2).*4.*pi.^2)-(nu_t.*4.*pi.^2.*jeta.*eta)-(F.*2.*pi.*1i.*jeta));
%% Initial condition %%
F(1) = 0; G(1) = 0;
%% Main calculation %%
for i = 1:L+1
t(i+1) = t(i)+dt
k1F = f(t(i), F(i), G(i));
k1G = g(t(i), F(i), G(i));
k2F = f(t(i)+dt./2,F(i)+dt./2.*k1F,G(i)+dt./2.*k1G);
k2G = g(t(i)+dt./2,F(i)+dt./2.*k1F,G(i)+dt./2.*k1G);
k3F = f(t(i)+dt./2,F(i)+dt./2.*k2F,G(i)+dt./2.*k2G);
k3G = g(t(i)+dt./2,F(i)+dt./2.*k2F,G(i)+dt./2.*k2G);
k4F = f(t(i)+dt, F(i)+dt.*k3F, G(i)+dt.*k3G);
k4G = g(t(i)+dt, F(i)+dt.*k3F, G(i)+dt.*k3G);
F(i+1) = F(i) + (dt./6).*(k1F + 2.*k2F + 2.*k3F + k4F);
G(i+1) = G(i) + (dt./6).*(k1G + 2.*k2G + 2.*k3G + k4G)
end
t = 1×201
0 0.0050 0.6000 0.9000 1.2000 1.5000 1.8000 2.1000 2.4000 2.7000 3.0000 3.3000 3.6000 3.9000 4.2000 4.5000 4.8000 5.1000 5.4000 5.7000 6.0000 6.3000 6.6000 6.9000 7.2000 7.5000 7.8000 8.1000 8.4000 8.7000
Unable to perform assignment because the left and right sides have a different number of elements.

Réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by