Populating matrix with coordinates of each element
Show older comments
Hi Guys,
I am trying to populate a 100x100 matrix so that the first element is assigned to 1 and the last element is assigned to 100.
Any suggestions? I've already create the specified matrix using zeros and ones but I am guessing I have to use a nested for-loop with the outer looping over the rows and the inner looping over the columns to reassign each element?
Any assistance would be much appreciated.
5 Comments
the cyclist
on 28 Aug 2021
You have not fully specified the matrix.
Let's take a smaller example: 3x3 matrix. Can you write out what you mean? For example, this is a matrix with the first element 1, and last element 3.
M = [1 0 0;
0 0 0;
0 0 3];
Is that what you mean?
Will Pihir
on 29 Aug 2021
Matt J
on 29 Aug 2021
That would be a 10x10 matrix, not 100x100.
Will Pihir
on 30 Aug 2021
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!