Custom Vector - make vector x to be [1,1,....]
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello Experts,
I want to create a vector x where all n elements are for example c.
I can do this by:
n=5;
x=zeros(1,n);
x(x==0) = 1;
But how to do this in more simple way.
Thanks a lot!
0 comentarios
Respuesta aceptada
Walter Roberson
el 7 de Oct. de 2011
repmat(c,1,n)
or
c * ones(1,n)
or
c + zeros(1,n)
or
c(ones(1,n)) %yes, even with scalar c
1 comentario
Más respuestas (1)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!