create a function that takes a vector as an input parameter and returns another vector where each component is the initial vector repeated n times.
Mostrar comentarios más antiguos
create a function that takes a vector as an input parameter and returns another vector where each component is the initial vector repeated n times.
I have thought about doing the following:
function B = cyclic_shift_recursion(A,n) %n is the number of times the vector is repeated and A is the vector that I want to repeat
if n<=0
return
else
B=[A cyclic_shift_recursion(A,n-1)];
end
end
I get an error and I do not understand why, how can I correct this? Is there another easy way to do this? Thank you.
Respuesta aceptada
Más respuestas (1)
Geoff Hayes
el 21 de Mzo. de 2019
1 voto
Nathali - what is the error message? What is cyclic_shift_recursion? Consider using repmat since your homework is indicating that you need to repeat each component in the initial array n times...
1 comentario
Nathali Londoño Torres
el 21 de Mzo. de 2019
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!