Calq commands and keywords

Keyword

function

Definition

This keyword begins a user-defined function. It should be located after the program, and will be treated as the end of the program. In the example below, we call the function "myfunction" with a parameter of 3. Control transfers to that function, where we find "out = 2*in;". Since "in" is the identifier for parameter 1, this will find 2*3 and store the result in "out". At the end of the function, control returns to the calling line, and "out" is passed on and stored as "b". We then display "b", and the program ends. Variables "in" and "out" will not be available after the function call.

Example

  b = myfunction(3);
  disp(b);
  function out = myfunction(in)
  out = 2*in;

See also

return


What is Calq?
Latest version of Calq
Digital Wave Systems Lab homepage