Would like help on how to change the values in a row and column of a 10x10 array?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2014-11-3
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".
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!