Hello, this block of code was given on a previous exam(adsbygoogle = window.adsbygoogle || []).push({});

And we are supposed to give the final output of temp. I have no idea how one loops over a matrix, not even elements or anything. What the heck does k = M mean?Code (Text):M = [1 3 -2; 7 -5 1];

temp = 0;

for k = M

temp = temp + k(2)

end

temp

So I just do temp = 0+7 on the first iteration, but what happens on the next iteration? temp = 7 + 7?? I ran this code and got 3. Does the value of k(2) change or something?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# [Matlab] looping a matrix?

Tags:

**Physics Forums | Science Articles, Homework Help, Discussion**