Hi David,
Thank you for your help. I understood the issue and corrected it appropriately in my code. It works fine although this has led me to a different problem.
Question - Can we reassign a variable in a loop?
In[2595]:= For[i = 1, i <= 1, i++,
sol = NDSolve[{eqR1, eqR2, R[(i - 1)*dt] == Last[Ro],
R'[(i - 1)*dt] == Last[Rpo], m[(i - 1)*dt] == Last[mo]}, {R[t],
m[t]}, {t, (i - 1)*dt, i*dt}];
Rbubble[t_] = R[t] /. sol;
Plot[Rbubble[t], {t, (i - 1)*dt, i*dt}]
BubbleRate[t_] = Rbubble'[t];
Plot[BubbleRate[t], {t, (i - 1)*dt, i*dt}]
mdot[t_] = m[t] /. sol;
Plot[mdot[t], {t, (i - 1)*dt, i*dt}]
checktemp = Last[Rbubble[(i)*dt]]
]
checktemp = Last[Rbubble[(i - 1)*dt]]
During evaluation of In[2595]:= Set::write: Tag Times in 0 is Protected. >>
Out[2596]= 0.0000500319
The assignment of checktemp inside the loop gives an error, however, a similar assignment outside the loop works fine. How should I overcome this?
Question 2: In the code above, I am extracting the value from function Rbubble using "Last". Is there a better way to get the value as an output rather than a list?
Please help!
Thanks.
P.S. - I am not sure if my work allows me to share those equations hence, I just uploaded the code essential to the issue. Sorry for the inconvenience.