Move and swap elements between vectors using loops and functions?
3 ビュー (過去 30 日間)
古いコメントを表示
lets say there are four vectors each has different dimension as follow: A=[5 7 11 15 17], B=[4 14 19 21], C=[2 6 9 10 13 18], D=[3 8 12 16 20]
First, I wan to remove elements of A to B one by one(each time one element should be moved) vice versa from B to A, and the same for C and D. Secondly, I want to swap elements of A with B ( also each time just one swap), and the same for C and D.
How can I do both steps move and swap using loops and functions?
4 件のコメント
Jan
2017 年 12 月 6 日
@Hajem: Okay, no homework. Then please answer my questions for clarifications. What does "remove elements from A to B" mean? Create the wanted output manually for the posted example data. The same for "swap elements". The terms are neither unique nor clear.
採用された回答
Jos (10584)
2017 年 12 月 6 日
Vague question → vague answer:
% swap at position k
k = 3
c = A(k)
A(k) = B(k)
B(k) = c
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!