Move and swap elements between vectors using loops and functions?
Mostrar comentarios más antiguos
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 comentarios
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
el 6 de Dic. de 2017
Jan
el 6 de Dic. de 2017
@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
el 6 de Dic. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!