Move string values to different variables

4 visualizaciones (últimos 30 días)
Jose Grimaldo
Jose Grimaldo el 1 de Abr. de 2020
Comentada: Walter Roberson el 1 de Abr. de 2020
I have a string array 6x1 and I want to move the odds index string to variable v1 and the even index string to v2. I want to do it using loops.
A=string array 6x1
[row,col]=size(A)
v1=A(1);
v2=A(2);
for x=1:row-1
v1(x)=A(x+(x+1))
V2(x)=A(x+2)
end
  1 comentario
Walter Roberson
Walter Roberson el 1 de Abr. de 2020
v1(x)=A(x+(x+1))
V2(x)=A(x+2)
when x is 1, then that would be A(3) and A(3) .
when x is 2, then that would be A(5) and A(4)
When x is 3, then that would be A(7) and A(5) but A(7) does not exist

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by