Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

function LASTONE clear; dt = .1; tspan = [0:dt:20]; IN = zeros(1,length(tspan));

ID: 3860257 • Letter: F

Question

function LASTONE
clear;

dt = .1;
tspan = [0:dt:20];
IN = zeros(1,length(tspan));
IN(8 <= tspan < 8.1) = 10;

KOB = 0;
KLB = 0.5;
KBO = 0.9;
KBL = 0.8;
KLO = 0.3;

y0 = [0 0];

[t,y] = ode45(@(t,y)hwfun(t,y,IN,KOB,KLB,KBO,KBL,KLO),tspan,y0);

figure;
plot(t,y(1,:),'r',t,y(2,:),'b-');

end

function dy = hwfun(~,y,IN,KOB,KLB,KBO,KBL,KLO)

dy = zeros(2,1);

dy(1) = (KOB + (KLB .* y(1,:)) - (KBO + KBL) .* y(2,:) + IN);
dy(2) = ((KBL .* y(2,:)) - (KLO + KLB) .* y(1,:));

end

Here is my code but I keep getting this error so idk what im doing wrong. Any help would be appreciated

In an assignment A(:) = B, the number of elements in A and B must be the same.

Error in LASTONE>hwfun (line 30)
dy(1) = (KOB + (KLB .* y(1,:)) - (KBO + KBL) .* y(2,:) + IN);

Error in LASTONE>@(t,y)hwfun(t,y,IN,KOB,KLB,KBO,KBL,KLO) (line 17)
[t,y] = ode45(@(t,y)hwfun(t,y,IN,KOB,KLB,KBO,KBL,KLO),tspan,y0);

Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ode45 (line 115)
    odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);

Error in LASTONE (line 17)
[t,y] = ode45(@(t,y)hwfun(t,y,IN,KOB,KLB,KBO,KBL,KLO),tspan,y0);

The mathematical representation of the model is B = k_OB + k_LB L - (k_BO + k_BL)B + IN L = k_BLB - (K_LO + k_LB)L where the rates are K_OB = 0, k_LB = 0.5, k_BO = 0.9, k_BL = 0.8, k_LO = 0.3, and the initial concentrations are L = B = 0 Use one of the MATLAB's ODE solvers, to find the dynamics of the drug 1.A. concentrations in the liver, L, and the blood, B, assuming that 10-unit injection was administrated at time 8 during 0.1 time units. In other words IN = {0, for t

Explanation / Answer

function LASTONE
clear;

dt = .1;
tspan = [0:dt:20];
IN = zeros(1,length(tspan));
IN(8 <= tspan < 8.1) = 10;

KOB = 0;
KLB = 0.5;
KBO = 0.9;
KBL = 0.8;
KLO = 0.3;

y0 = [0 0];

[t,y] = ode45(@(t,y)hwfun(t,y,IN,KOB,KLB,KBO,KBL,KLO),tspan,y0);

figure;
plot(t,y(1,:),'r',t,y(2,:),'b-');

end

function dy = hwfun(~,y,IN,KOB,KLB,KBO,KBL,KLO)

dy = zeros(2,1);

dy(1) = (KOB + (KLB .* y(1,:)) - (KBO + KBL) .* y(2,:) + IN);
dy(2) = ((KBL .* y(2,:)) - (KLO + KLB) .* y(1,:));

end