Would like help on how to change the values in a row and column of a 10x10 array?
1 view (last 30 days)
Show older comments
Given a 10 by 10 array of zero's named M2, change the values in row 3 and column 7 to all ones? This is how far I got but I cant seem to get it right... Any help would be appreciated
M2 = zeros(10, 10);
N = M2(3:end, 7:end);
col_row_Of_Ones = ones(N)
0 Comments
Accepted Answer
Image Analyst
on 3 Nov 2014
No. Do it in two steps, once for the row, and once for the column. Here, I'll do the column for you.
M2(:, 7) = 1;
Get rid of your last two lines and do something similar to what I did, except that you will do it for row 3 and all columns. Remember ":" means "all".
More Answers (0)
See Also
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!