Solllvinf first order dffnt eqn

1 view (last 30 days)
Hello, I have to solve a set of three equations:
I have to solve these using ode45. I tried solving it but my code faced a few errors.
But I am getting a few errors I do not understand.

Accepted Answer

Steven Lord
Steven Lord on 24 Jan 2022
If you're going to put spaces around the operators separating terms in the matrix you're creating in example, be consistent.
y0 = [1 -1 0];
tspan = [0 pi/2];
[t,y] = ode45(@example, tspan, y0);
figure
plot(t,y(:,1)), hold on
plot(t,y(:,2)), hold on
plot(t,y(:,3)), hold off
function yp = example(t,y)
yp=[2*y(1) + y(2) + 5*y(3) + exp(-2*t);
-3*y(1) - 2*y(2) - 8*y(3) - cos(3*t);
3*y(1) + 3*y(2) + 2*y(3) + cos(3*t)];
end

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!