how to insert same scalar as length of something?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Steven Lord
2022-8-23
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 个评论
更多回答(1 个)
Abderrahim. B
2022-8-23
编辑:Abderrahim. B
2022-8-23
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!