Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

functions




fprintf('######### Anonymous Functions  ################\n')

power = @(x, n) x.^n;

result1 = power(7, 3)
result2 = power(49, 0.5)
result3 = power(10, -10)
result4 = power (4.5, 1.5)



fprintf('######### Functions  ################\n')

function avg = average(nums)
global TOTAL
avg = sum(nums)/TOTAL;
end

TOTAL = 10;
n = [34, 45, 25, 45, 33, 19, 40, 34, 38, 42];
av = average(n)




Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.