Move string values to different variables
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 1 Avr 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
Réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!