how to insert same scalar as length of something?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sierra
el 23 de Ag. de 2022
Respondida: Steven Lord
el 23 de Ag. de 2022
Let's suppose, A = [1, 2, 3, 4, 5] and B = [0].
I want to make second [0,0,0,0,0] whose length is 5.
Please Let me know how to do this
0 comentarios
Respuesta aceptada
Steven Lord
el 23 de Ag. de 2022
If you want to replicate the scalar in B to be the same size as A, you can use repmat. If you know that B will always be 0, instead I'd just use the zeros function.
A = ones(3, 4)
B = pi
C = repmat(B, size(A))
D = zeros(size(A))
0 comentarios
Más respuestas (1)
Abderrahim. B
el 23 de Ag. de 2022
Editada: Abderrahim. B
el 23 de Ag. de 2022
Is this what you are trying to do?
A = [1,2,3,4,5] ;
myScalar = 2 ; % change this to the scalar value you want
B = myScalar*ones(size(A))
0 comentarios
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!