Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to Transform Script Function into M Function matlab
How to Transform Script Function into M Function matlab
Add a function header before the whole content:

Function [output 1 output 2 ...] = functionname (argv1,argv2, ...)

In the newer version, you also need to add an end at the end of the whole content of the file.

Please note that the functionname here must be the same as the file name.

Argv 1, argv2 are input parameters, and output 1 and output2 are output parameters.

As the simplest case, there are no input parameters and output parameters, so it can be written as:

Functionname ()

For the script script file, I think you may not have input parameters, but you may have output parameters. In other words, which result needs to be retained after processing, such as result, then the function header is written as:

Function Result = Function Name ()

Note that the result here must be a variable of the calculation result in your program, not an imaginary quantity.