Easiest way to make matrix have 3 sets of values
1 view (last 30 days)
Show older comments
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 Comments
Guillaume
on 25 Feb 2020
Indeed there are many many ways to create such a simple matrix, so more details are needed on the background behind the question.
Answers (1)
See Also
Categories
Find more on Operating on Diagonal Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!