Question: If we instead wanted to print from the bottom left to the top right, what would the criteria of the elements that fall on the

If we instead wanted to print from the bottom left to the top right, what would the criteria of the elements that fall on the diagonal be?(select all that will match the criteria of elements that should be printed)
In this week's lecture we looked at the schema of looking at each element of a 2D array, checking if the element matched a criteria and then taking some action if it matched (like printing it). The general pattern for this was:
[rows, cols]= size(M)
% look at each row
for r =1:rows
% look at all the columns in this row
for c =1:cols
if (meets criteria)
do_action
end
end
end
a condition for identifying the elements that fall on the right diagonal (starting from top right and going to bottom left) is:
if c == cols - r +1
disp(M(r,c));
end
If we instead wanted to print from the bottom left to the top right, what would the criteria of the elements that fall on the diagonal be?(select all that will match the criteria of elements that should be printed)
r + c == cols +1
r == c
r - c == cols -1
r == c -1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!