fill column elements with the column number?

2 次查看(过去 30 天)
How can I fill column elements with the column number. First column contains only 1, second only 2, third only 3, etc.

采纳的回答

Hayden Garmon
Hayden Garmon 2020-9-14
编辑:Hayden Garmon 2020-9-14
m=5;% m is length of columns
n=4;% n is number of columns
for i =1:n
A(:,i)=ones(m,1)*i ;
end
A =
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dynamic System Models 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by