repeating values in the loop
    9 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Offroad Jeep
 el 22 de Sept. de 2015
  
    
    
    
    
    Respondida: Jon
      
 el 22 de Sept. de 2015
            Hi to all,
Can anyone please remove the error in the attached file . I want to make a loop in which theta_new = theta_initial + dtheta. let result is 'a' now'a' should become theta_initial and and next value of dtheta should add like " a + dtheta" and so on ....... till last value of dtheta.
why the values are repeating.........
0 comentarios
Respuesta aceptada
  Jon
      
 el 22 de Sept. de 2015
        You are looping over j, but nothing in your equation is changing with respect to j. Only after all the j's are finished and i changes does your value change. The values are repeating hsteps times (100) before changing.
To see what's happening, just replace line 18 with
          theta_new(i,j) = theta_initial + dtheta(i);
and look at the theta_new matrix. Basically, the way you have this set up, there is no reason to have two loops since one is just repeating the same calculation 100 times.
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

