The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Given a matrix variable "mat", write code using for loops, if statements, etc. that will accomplish the same as the following:
matsum = sum(mat')
Please make sure to store the result in "matsum"!
This is what i have so far but matsum is incorrect, how can i do the sum(mat') with loops with out using sum
Â
% mat has been initialized for you:
mat = randi([-100,100],randi([15,20]),randi([15,20]));
% write your statements that accomplish the code above:
[r c]=size(mat);
for i=1:r
matsum=0;
for j=1:c
matsum=matsum+mat(i,j);
end
endÂ
-----------