MATLAB ODE solver and selection of function

24 Views Asked by At

The function is

function dx=f(x,i)
if nargin == 1 || isempty(i)
    dx = [2.*x(1)*(1-x(2));    % x1' = 2*x1*(1-x2) % compute for both
            (x(1)-20)+x(2)];   % x2' = (x1-20)+x2
  else
    switch i
      case 1                      % Compute only first component.
        dx = 2.*x(1).*(1-x(2));
      case 2                      % Compute only second component.
        dx = (x(1)-1).*x(2);
    end
  end

The ode solver is ode45(@f,[0,5],ones(1,1)) which solves both the equation by default. I want to choose only either first or second component in ode solver. How Can I specify that into ode {e.g*ode45(@f(1),[0,5],1)*}?

Thank you in advance