How to make new elements (columns) in a vector (matrix) based on the each value of this vector?

1 次查看(过去 30 天)
How to expand each element of a vector with ones based on the value of this element.
For example, if vector is: A=[4 2 3 ...], then the new vector will be: C=[1 1 1 1 1 1 1 1 1 ...]. So, the number of how many ones depend on the value of each element of this vector A.
Thanks, Khalid

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2016-8-14
A=[4 2 3]
C=ones(1,sum(A))
  3 个评论
kadaldu
kadaldu 2016-8-14
Thank you very much and this is exactly what I am looking for.
I really appreciate your time and support.
Regards, Khalid

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by