Question: programming languages (MATLAB) Let M be a matrix whose entries are positive integers. What does the following function do? function v=Summat (M) [m n]-size (M);
programming languages (MATLAB)
Let M be a matrix whose entries are positive integers. What does the following function do? function v=Summat (M) [m n]-size (M); v=zeros(n,1); for i=1:1 for j=1:m if mod (M(j, i),2)--0 v(i)=v(i)+M(),1); end end end Creates a vector whose ith entry is the sum of the odd elements of the ith column of M Creates a vector whose ith entry is the sum of the even elements of the ith column of M Creates a vector whose ith entry is the sum of the odd elements of the ith row of M Creates a vector whose ith entry is the sum of the even elements of the ith row of M
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
