Move string values to different variables

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2020-4-1
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by