About 131,000 results
Open links in new tab
  1. function - Declare function name, inputs, and outputs - MATLAB

    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. What is the @ operator (at sign) in MATLAB? - Stack Overflow

    Jan 20, 2010 · It used to declare Anonymous Functions in Matlab. I think the terms is "Function Handle". Practically it covers the inability of Matlab to declare a function at any place in any M file. You may see it here: What is your favourite MATLAB/Octave programming trick? I found it to be useful in Image Processing along with the "blockproc" command.

  3. declare complicated function in matlab - Stack Overflow

    Aug 16, 2012 · Third, if you want to find the roots of this function, you'd better use an extensively tested Matlab function dedicated to that purpose, rather than design & implement your own version:

  4. matlab - How to declare a function with an argument which is an …

    Oct 9, 2011 · Then in the function, you could either call argStruct.arg1, etc, directly; or unpack it into 32 different variables inside the function. I would give the fields descriptive names so you don't refer to them as arg1, etc inside your function. For that many input arguments, people using the function probably won't remember the order in which your ...

  5. matlab - Declaring variables before declaring a function - Stack …

    Apr 1, 2014 · A nested function. In this case, the function declaration and definition can be within another function of the preceding case. See here for more details. As you can see, in either case the file begins with a function declaration (namely that of the main function). The function can also be defined as an anonymous function. Then no declaration is ...

  6. math - Optional args in MATLAB functions - Stack Overflow

    Jul 20, 2011 · Mathworks:Function Argument Validation. There is a detailed description about how to user optional parameters in function. Also, you can learn how to use function like build-in matlab fun like. fun(arg1,'key1',value1) There is some example using the trick from above:

  7. Matlab - Defining a math function - Stack Overflow

    defines a symbolic function. This means that there is no loss of precision when using the function. The results are always exact: >> f(1) ans = 1 Also, you can apply symbolic operations to the function. For example, you can compute its derivative function, among other operations:

  8. Declaring a global variable in MATLAB - Stack Overflow

    Feb 6, 2011 · function[x] = test() global x; test1(); end Where the function test1() is defined as: function test1() x = 5; end When I run test(), my output is x = []. Is there a way I can make it output the x=5, or whatever I define x to be in a separate function? In C, this would be an external variable, and I thought making it a global variable should ...

  9. arguments - Declare function argument validation - MATLAB

    MATLAB creates a cell array that contains all the values passed in for that argument. Functions can include only one repeating input arguments block. If the function includes both repeating and name-value arguments, declare name-value arguments in their own, separate arguments block after the repeating arguments block.

  10. How do I set default values for functions parameters in MATLAB?

    Apr 28, 2009 · function f(arg1, arg2, arg3) if nargin < 3 arg3 = 'some default' end end There are a few fancier things you can do with isempty, etc., and you might want to look at MATLAB central for some packages that bundle these sorts of things. You might have a look at varargin, nargchk, etc. They're useful functions for this sort of thing.