A model for exponential growth of a quantity is given by: At= A0e^(kt) where k=(
ID: 3769944 • Letter: A
Question
A model for exponential growth of a quantity is given by:
At= A0e^(kt) where k=(1/t)ln(At/A0)
In these equations, At and A0 are the quantities at time t and time 0, respectively, and k is a constant that is unique to the specific application. Write a user-defined function that uses this model to find the quantity At. This function, should have four input arguements, 3 scalars A0, At1 and t1 as well as a matrix of values t with one output argument At. The function should verify that all input values are scalar values (not matrices) prior to continuing the calculations. I know that I am supposed to solve for k first using the input variables and then I should be able to solve for At but I'm a little lost on this Matlab problem, any help appreciated!
Explanation / Answer
function At=expGrowth(A0,At1,t1,T)
if isscalar(A0) and isscalar(At1) and isscalar(t1) and !isscalar(t)
k= (1/t)*log(At1/A0)
else
error('invalid input')
for i=T
At(end+1)=A0*exp(k*i)
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.