Would like help on how to change the values in a row and column of a 10x10 array?

2 views (last 30 days)
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)

Accepted Answer

Image Analyst
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)

Community Treasure Hunt

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

Start Hunting!