How do I exclude the first ten observations in the line plot generated by the three differential equations

4 visualizaciones (últimos 30 días)
close all
clear all
clc
tspan = [0 100];
y0 = 0.7; % initial value of state variable x1
r0 = 0.7; % initial value of state variable x2
w0 = 0.8; % initial value of state variable x3
x0 = [y0; r0; w0];
[t, x] = ode45(@odefcn, tspan, x0);
%% Plot x2 (y-axis) vs. x1 (x-axis)
subplot(3,1,1);
plot(t,x(:,1));
xlabel('Time')
ylabel('Output');
subplot(3,1,2);
plot(t,x(:,2));
xlabel('Time')
ylabel('Policy Rate');
subplot(3,1,3);
plot(t,x(:,3));
xlabel('Time')
ylabel('Wage Share');
y0 = [0.7; 0.7; 0.8];
%% System of three differential equations
function dx = odefcn(t, x)
% definitions
y = x(1);
r = x(2);
w = x(3);
% parameters
alpha = 1.0;
beta = 1.0;
gamma = 0.1;
delta = 0.3;
mu = 1.0;
lambda = 0.3;
theta = 0.1;
omega = 0.2;
% ODEs
dx(1,1) = alpha * y - beta * r * y;
dx(2,1) = - omega * r + gamma * w * r + delta * y * r;
dx(3,1) = - theta * w + lambda * y * w - mu * w * w;
end
  6 comentarios
Torsten
Torsten el 5 de Jun. de 2025
It's still not clear what you mean.
If you define
tspan = [0 100];
ode45 will choose the output times between 0 and 100 on its own. Thus excluding the first ten outputs does not tell you anything about the time points when these ten outputs were reported: they could be [0 1 2 3 4 5 6 7 8 9] or any other increasing vector with 10 elements starting at 0.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 4 de Jun. de 2025
Editada: Matt J el 4 de Jun. de 2025
One way,
tspan = [0 100];
y0 = 0.7; % initial value of state variable x1
r0 = 0.7; % initial value of state variable x2
w0 = 0.8; % initial value of state variable x3
x0 = [y0; r0; w0];
[t, x] = ode45(@odefcn, tspan, x0);
x(1:10,:)=nan;
  6 comentarios

Iniciar sesión para comentar.

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by