Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
May 2nd, 2013, 05:58 AM
 mrhlth
Registered User

Join Date: Mar 2013
Posts: 17
Time spent in forums: 6 h 16 m 18 sec
Reputation Power: 0
[matlab] help with question

so the question i have is:
Write a single function that takes in a square integer matrix A and the scalars N and G, as well as a 2-value vector R indicating the inclusive range [R(1), R(2)] as inputs.
Has to return:
(1):average of the elements in the nth column
(2):value of the most occuring element
(3):the number of elements within a specified range R, inclusive of the edge values
(4):a Mx2 matrix, with each row containing two elements to represent the indicial position (i.e. row number, column number) of each appearance of the number G.

So far what i have:
(1)
Code:
```if (N > size(A,2))
fprintf('N is out of range of columns');

else
for i = A(:, N)
A2 = A2 + i;
end

end
fprintf('A1 is %d, A2 is %d', A1, (A2/i));```

and the rest im still doing them, dont think i can do 3 and 4 but 2 should be no problem... any pointers/tips would be great! thanks

 Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > [matlab] help with question