Move string values to different variables
2 ビュー (過去 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
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 Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!