# How to Execute loop continuously based on vector elements

1 visualización (últimos 30 días)
Raghavendra Reddy P el 13 de Feb. de 2015
Respondida: Amith el 2 de Mzo. de 2023
I have two vectors >> V=1:12; >> L=[ 3 5 8 10] starting from last element of vector L
for i=1:12 if L==10 V(i)=V(i+2)-10*V(i) .... .. next if L==8 do stuff .. .. if L==5 .. .. if L==3 .. ... .. end how could i do this for all elements of L starting last to first in loop fashion..
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Amith el 2 de Mzo. de 2023
As per my understanding you want to write a code such that a for loop for array ‘v’ goes in forward direction while another array L goes in the reverse direction to do some functions for a particular L, the code below demonstrates it.
V = 1:12;
L = [3 5 8 10];
j = length(L)
for i = V
switch j
case 1
disp('do something 1')
case 2
disp('do something 2')
end
j = j-1;
end
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### 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!

Translated by