I wrote this code, but I'm always getting "unable to perform assignment because the left and right sides have a different number of elements."
clearvars; close all; clc;% rate
rI = 2; rp = rI/100;dp = rp;KP = 40000;beta = 2000;tmax = 500; time = 0:.1:tmax;% pre-allocate for I
I = zeros(length(time), 1);% initial I
I(1) = 50;% pre-allocate for P
P = zeros(length(time), 1);% initial P
P(1) = 1100;for t = 1:length(time)-1 I(t+1) = I(t) + ( (rI * I(t)) * (1 - (I(t) / f(P)))) - ((beta * (I(t).^2)) / ((g(P).^2) + (I(t).^2))); P(t+1) = P(t) + (rp * P(t)) * (1 - (P(t) / KP)) - (dp * I(t));end%%%%%%%%% functions %%%%%%%%
function KI = f(P)KI = 4*P;endfunction alpha = g(P)alpha = P/2;end
Best Answer