Skip to main content
Library homepage
 
Engineering LibreTexts

5.7: Matlab Functions with No Inputs

  • Page ID
    84406
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Tags recommended by the template: article:topic

    By Carey A. Smith

    Functions can have outputs, even though they have no input arguments.

    These are some built-in Matlab functions with no inputs:

    date % Try it

    datetime % Try it

    The function definition of such a file would be like this:

    function [date1] = date()

    An interesting Matlab function with no inputs is:

    pi

    This is used as a constant, but it is an actual function. You could define your own functions for constants such as Avogadro’s number, the universal gravitational constant, the speed of light, or a parsec’s distance.


    This page titled 5.7: Matlab Functions with No Inputs is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Carey Smith.