-1

For a homework assignment, my professor asked us to solve a system of differential equations using MATLAB. Using the mathworks website, I did

syms f(t) g(t) h(t)
[f(t), g(t), h(t)] = dsolve(diff(f) == .25*g*h,...
diff(g) == -2/3*f*h,...
diff(h) == .5*f*g, f(0) == 1, g(0) == -2, h(0) == 3)

However, I get an error saying that an explicit equation cannot be solved.

double-beep
  • 5,031
  • 17
  • 33
  • 41

1 Answers1

0
%x(1),x(2),x(3)=f,g,h

fun = @(t,x) [0.25*x(2)*x(3); -2/3*x(1)*x(3);
-0.5*x(1)*x(2)];
[t,x] = ode45(fun,[0 100],[1 2 3]);
plot3(x(:,1),x(:,2),x(:,3))
%x has three columns which contains values of f,g,h as a function of time from %time t=0 to t=100
%please check ode45 in matlab to see what these arguments mean
pavan
  • 1
  • 2