Move and swap elements between vectors using loops and functions?
显示 更早的评论
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 个评论
This sounds like a homework question. Then please mention, if it is one, because this demands for another kind of answering. Post, what you have tried so far and ask a specific question. It would not be useful, if the forum solves your homework.
What does "remove elements of A to B" mean? What should be removed? A and B do not have common elements.
How can you swap elements of A and B one by one, if they have a different number of elements?
If this is really a homework, let me mention, that this is the most useless problem I've ever seen. I cannot imagine, what you should learn from programming this strange process.
Hajem Daham
2017-12-6
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.
Hajem Daham
2017-12-6
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!