Errors of not having enough input
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The code is attached. The error displays not enough imput
0 commentaires
Réponses (1)
Radhe Saini
le 29 Oct 2022
In Matlab, all local functions are to be added at the end of the file. As you are adding "function dz = fun_atherosclerosis(t,z)" in the first line, MATLAB treats this entire script as a single file and returns you the error, "Not Enough Inputs.". Just shift the function to the end of the script and add an "end" line at the end of the function.
The modified code is:
%%% This code is to simulate Problem 12.3
%% parameters
global L_0 k_1 K_1 r_1 H_0 k_2 K_2 r_2 lambda delta mu_1 mu_2
k_1 = 1.4; % /day
k_2 = 10; % /day
K_1 = 10^(-2); % g/cmˆ3
K_2 = 0.5; % g/cmˆ3
mu_1 = 0.003; % /day
mu_2 = 0.005; % /day
r_1 = 2.4*10^(-5); % /day
r_2 = 5.5*10^(-7); % /day
lambda = 2.57*10^(-3); % day
delta = 2.54*10^(-5); % /day
M_0 = 5*10^(-4); % g/cmˆ3
L_0 = 200*10^(-5); % g/cmˆ3
H_0 = 40*10^(-5); % g/cmˆ3
%% initial conditions
z_ini = [L_0, H_0, M_0, 0];
tspan = [0,300];
%% solve ODEs
[t,z] = ode15s(@(t,z) fun_atherosclerosis(t,z), tspan,z_ini);
w = z(:,3) + z(:,4);
R = w./M_0;
%% Plot
% plot 4 subplots for each species
figure(1)
labelvec = {'L','H','M','F'};
for i = 1 : 4
subplot(2,2,i)
plot(t,z(:,i))
xlabel('t'), ylabel(labelvec(i))
end
function dz = fun_atherosclerosis(t,z)
global L_0 k_1 K_1 r_1 H_0 k_2 K_2 r_2 lambda delta mu_1 mu_2
dz = zeros(4,1);
L = z(1);
H = z(2);
M = z(3);
F = z(4);
dz(1) = L_0 - k_1*M*L/(K_1+L) - r_1*L;
dz(2) = H_0 - k_2*H*F/(K_2+F) - r_2*H;
dz(3) = - k_1*M*L/(K_1+L) + k_2*H*F/(K_2+F)+ lambda*M*L/(H-delta) - mu_1*M;
dz(4) = k_1*M*L/(K_1+L) - k_2*H*F/(K_2+F) - mu_2*F;
end
0 commentaires
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!