Looks okay when invoked from ode*(), which suggests that VBBV might be correct in hinting that you are invoking it some other way with a vector of t values.
No. It means that in any one call to fix_reaksi_tumor_gliom() the first parameter, t, must be a scalar or else your code will not work.
There is another possibility, if you have good reason to pass in a vector of t values (which would not happen if you use the function with ode45() or similar):
function dydt = fix_reaksi_tumor_glioma(t,y)
dydt = zeros(numel(y), numel(t));
% Parameter model pertumbuhan glioma (1 g/ml = 10^3 mg/ml)
B = y(2); % konsetrasi glukosa dalam otak (obrain)
I = y(3); % aktivitas sistem kekebalan tubuh (imune)
S = y(4); % konsentrasi glukosa dalam serum (oserum)
dydt(1,:)= aT*B*T*(1-T/KT) - dT*T - dTI*T*I;
dydt(2,:)= ao*(S-B) - dTo*T*B - (do1+as*(v+I))*B;
dydt(3,:)= as*(v+I)*B + aTI*T*I - dI*I - dTT*T*I;
dydt(4,:)= ao*(B-S) + f_glukosa - do2*S;
end
This change is compatible with calling from ode45() because ode45() and related functions will only ever pass in a scalar t, but the change also permits you to call the function with a vector of t values, and will return one column for each t value.
t(:) takes whatever values are in t and makes a column vector out of them. The .' after that transposes the column vector into a row vector. t(:).' is a short way of writing reshape(t, 1,[])
The reason why I coded that is that if t is not a scalar then it takes too much explanation and self discipline to force it to be either a row vector or a column vector specifically. If I had coded assuming it was a column vector you might have replied that it was a row vector or 2d array and I would have had to adjust the code to handle whatever you turned out to be passing in. It saved rounds of back and forth with you and future readers for me to code it the first time in a way that did not depend on what exactly the input shape is.
I already demonstrated above that your original function works without change with ode45. The only change I made was to add a final "end" to your code, which is required if you use the function in a script the way I did here, but would not be necessary if you had stored the code in its own fix_reaksi_tumor_glioma.m file.
The changes I made later with the t(:) and so on are only needed if you are invoking the function in your own custom code, such as if it had turned out that you are building your own RK45 or Euler integration function.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
0 Comments
Sign in to comment.