I want to write in Matlab a function that appreciates the fixed point iteration for a system of equations. The idea is:
$\begin{bmatrix} x{_{1}}^{m+1}\\ x{_{2}}^{m+1} \end{bmatrix}= \begin{bmatrix}y{_{1}}^{n}+hf{_{1}}(x{_{1}},x{_{2}})\\ y{_{2}}^{n}+hf{_{2}}(x{_{1}},x{_{2}}) \end{bmatrix}$
The iterations stop when $ |x_{1}^{m+1} -x_{1}^{m}|<TOL$ and $ |x_{2}^{m+1} -x_{2}^{m}|<TOL$ or when m arrives the limit of iterations M...
At the function, do I have to write : if ($|x_{1}^{m+1} -x_{1}^{m}|<TOL$ && $|x_{2}^{m+1} -x_{2}^{m}|<TOL $){ $y_{1}=x_{1}^{m+1}$; $y_{2}=x_{2}^{m+1}$; } ? But when only one of them is smaller than TOL how can it get its value ??
&&. – Shuhao Cao Jun 02 '13 at 22:36y_{1}and put it in MATLAB, I believe MATLAB will give you a syntax error. – Shuhao Cao Jun 02 '13 at 22:45At the Backward Euler Code, I wrote: for n=1:N [Y1,Y2]=stage(y1(n),y2(n),h,t(n)); t(n+1)=t(n)+h; y1(n+1)=y1(n)+hS(t(n+1),Y1,Y2); y2(n+1)=y2(n)+hG(t(n+1),Y1,Y2); end
(stage() is the function of the fixed point iteration) What I'm doing wrong??
– Mary Star Jun 03 '13 at 01:07ode45...you know...Actual coding is never ever never ever done by hand first, pseudo-code and structure maybe, but you have to test your code line by line by choosing appropriate testing cases. – Shuhao Cao Jun 03 '13 at 01:10