%input is a matrix %(of any size, including vector or scalar) % x and a power p %takes each element of x to power p %then sums every element function f=elementwise_power_then_sum_function(x,p) y=x.^p; f=mysum(y); end %if mysum isn't defined elsewhere, define it right here function g=mysum(A) g=sum(sum(A)) ; end