About 18,500,000 results
Open links in new tab
  1. function - MathWorks

    function [y1,...,yN] = myfun(x1,...,xM) declares a function named myfun that accepts inputs x1,...,xM and returns outputs y1,...,yN. This declaration statement must be the first executable line of the function. Valid function names begin with an alphabetic character, and can contain letters, numbers, or underscores.

  2. How to create a function in MATLAB - GeeksforGeeks

    May 6, 2021 · Below are some examples that depict how to use functions in MATLAB: Example 1: Function with one output. The function calculates the mean of the input vector. Output : Example 2: Function with multiple outputs. The function calculates both nCr and nPr of inputs n and r. Output : Example 3: Multiple functions in a file.

  3. Create Functions in Files - MathWorks

    The body of a function can include valid MATLAB expressions, control flow statements, comments, blank lines, and nested functions. Any variables that you create within a function are stored within a workspace specific to that function, which is separate from the base workspace.

  4. Function Creation - MathWorks

    Create Functions in Files. Store multiple commands in a program file that can accept inputs and return output. Types of Functions. There are several types of functions available with MATLAB ®, including local functions, nested functions, private functions, and anonymous functions. Anonymous Functions; Local Functions

  5. Functions in MATLAB - GeeksforGeeks

    Aug 16, 2021 · MATLAB syntax is quite peculiar compared to other programming languages. We can return one or more values from a function. We can also pass one or more arguments/variables while calling a function. MATLAB functions must be defined in separate files and function name must match with the file name.

  6. How to Call a Function in MATLAB - wikiHow

    Mar 6, 2025 · Start your script with function followed by the name you want to assign it. After writing your function in the script editor, call it using the format yourfunction (inputvalue1, inputvalue2, inputvalueN). Open up MATHWORKS MATLAB and press the New Script button. This button will be on the upper left side of your screen. Type your function name.

  7. How to Create a Function in MATLAB - Delft Stack

    Feb 2, 2024 · A function in Matlab consists of mainly three things output, input, and function name. To define a function, we use the variable function, and then we define the outputs, the function name, and the inputs of the function.

  8. The How and Why of Writing Functions - MathWorks

    Increase code modularity and flexibility by writing custom functions. Debug functions, set the MATLAB path, and understand function precedence to resolve ambiguity in command and function names.

  9. How to Write a Function in Matlab: A Simple Guide

    This guide unpacks the essential steps and tips for crafting your own MATLAB functions. To write a function in MATLAB, you define it using the `function` keyword, specify the output and input parameters, and then include the code to execute within the function body. output = input^ 2; % Example: returns the square of the input end.

  10. Programming with MATLAB: Creating Functions - GitHub Pages

    Feb 28, 2025 · Learn how to write a function; Define a function that takes arguments. Compare and contrast MATLAB function files with MATLAB scripts. Recognise why we should divide programs into small, single-purpose functions.

  11. Some results have been removed
Refresh