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.

 채택된 답변

Steven Lord
Steven Lord 2022년 1월 24일

0 개 추천

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

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

질문:

2022년 1월 24일

편집:

2022년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by