Posts

Showing posts with the label append

How to make empty lists in MATLAB Live Script and append to them both outside of a loop and inside one? [closed]

How to make empty lists in MATLAB Live Script and append to them both outside of a loop and inside one? [closed] The three list I want to make are the following and I'm not sure how it's done in MATLAB. na = nb = t Outside of the list I want to append the follwoing: NA = input('Enter intial number of atoms of A > '); NB = input('Enter intial number of atoms of B > '); tau_a = input('Define decay constant of A >'); tau_b = input('Define decay constant of B >'); time = input('the total time >'); dt = input('Define time increment >'); I've to append the values like so: na = [na, NA] nb = [nb; NB] t = [t, 0] Finally, inside the loop I have tried appending values like this: for i = int16(time/dt) nai = na[i]-(na[i]/tau_a)*dt nbi = nb[i]+((na[i]/tau_a)-(nb[i]/tau_b))*dt ti = t[i]+dt na = [na, nai] nb = [nb, nbi] t = [t, ti] end But it is not working. It does not want to append the values. ...