matlab --error: index must be a positive integer or logical -- how to make movie -


I have this matlab code and this gives me an error in my headline.

  Scalar wave 1d equation time = 1000 solution; Stages = 1000; A = input ('Please enter the value ratio cdt / dx:'); % Preterocate matrix u u = zero (step, time); Fill the matrix for% I = 1: time = 1 for Jammu = 1: phase-1 if (i == 1) u (j, i) = 1; Edited - gt; & Gt; = 0% initial condition and edit from U (J, I) - & gt; & Gt; Jammu == 1 and I == 1 Jammu == 2, I == 2 if time (Jay == 2 & amp; i> = 2 & amp; i & lt; = 50) is the time period for% 50 Pulse's U (J, I) = 50; Second solution of waveform equation U (J, I + 1) = one * A * (U (J + 1, I) -2 * (U, I) + U (J-1, I)) + 2 * U (J, I) -U (J, I-1); - & gt; Here is the end end end error for Kashmir: Edit the phase - & gt; Plot (U (K, 1: 100)) Plot (U (K, 1: 200)) Plot (U, 1: 200) Plot (U (:, I + 1)) Plot (U (K, 1: 300) )) Plot (U (K, 1: 400)) .... end   

In addition, how do I more efficiently past loop plot) and how do I create a movie? Edit - & gt; Resolved

U (J, I-1) and U (J-1, I) undefined When i and j = 1; Remember, MATLAB matrix starts with index 1, not 0

Comments