1. Simple SUM function files
  2. function[sum4]=mySum4(a1,b1,c1,d1) % to call the function, you have to write mySum4 (2,3,4,5) and it will return what sum4 is represented by sum4=a1+b1+c1+d1; 
  3. Simple Mutiplying Function
  4. function[sum,difference,product,ratio]=myOperations(a2,b2) % calling the function in the command window to compute myOperations on TWO mumbers will return its sum, difference, product and ration 
    sum=a2+b2; % individually define what each part of the function means
    difference=a2-b2;
    product=a2*b2;
    ratio=a2/b2;
  5. Creating a list of numbers
  6. function[x]=makeList(first,last,spacing)
    i=1;
    while first<=last % execute while in the range
      x(i)=first; % x(1)= what the user puts as first value
      first=first+spacing; % reassigns first with new value
      i = i+1; % so that x(2)=newly reassigned first
    end
Advertisements