Easiest way to make matrix have 3 sets of values
1 次查看(过去 30 天)
显示 更早的评论
Easiest way to simplify the code below?
matrix = zeros(8,1)
for i = 1:3
matrix(i,1) = 1;
end
matrix(4,1) = 2
for i = 5:8
matrix(i,1) = 3
end
Ouput
1
1
1
2
3
3
3
3
3 个评论
Guillaume
2020-2-25
Indeed there are many many ways to create such a simple matrix, so more details are needed on the background behind the question.
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!