Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. function [doubleNumber] = doubleIt(x)
  2.  
  3. %Function: doubleIt
  4. %Input: x, a number
  5. %Output: doubleNumber, a number
  6. %Purpose: Takes an input number (x), multiplies it by 2, stores it as
  7. %doubleNumber and returns the number to the user
  8. %Use: From command prompt you type 'doubleIt(x)' where x is a number
  9. %Example: doubleIt(8) returns 16
  10.  
  11. doubleNumber = 2*x; %Notice that 'x' is never actually defined in the function,
  12. %it is 'passed' to the function
  13.  
  14. %doubleNumber is the variable 'returned' by the fuction
  15. %It is automatically returned based on the first line of the function
  16.  
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement