Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a function be created in MATLAB that returns nothing?

Tags:

I want to write a function that does some image processing and writes the processed images to files. I don't want it to return anything. I can always return a dummy variable which can be ignored, but I'd like to keep my code clean. How can I achieve this in MATLAB?

like image 481
Aashish Thite Avatar asked Oct 20 '12 21:10

Aashish Thite


People also ask

Can a function in MATLAB have no inputs?

The input parameters to the function will be void (that is, no input) and the output will be the two arrays defined in the function. Once you program works, I can then substitute the experimental data.

Can a function return in MATLAB?

return forces MATLAB® to return control to the invoking program before it reaches the end of the script or function. The invoking program is a script or function that calls the script or function containing the call to return .

What does find return if nothing is found MATLAB?

indices = find(X) returns the linear indices corresponding to the nonzero entries of the array X . If none are found, find returns an empty, 0-by-1 matrix.

What functions Cannot be used inside a function MATLAB?

However, to nest any function in a program file, all functions in that file must use an end statement. You cannot define a nested function inside any of the MATLAB® program control statements, such as if/elseif/else , switch/case , for , while , or try/catch .


1 Answers

Yes.

function [] = my_awesome_function(image,filename,other_inputs)     % Do awesome things. end 

will return nothing. An even simpler version:

function my_awesome_function(image,filename,other_inputs)     % Do awesome things. end 

is equivalent.

like image 196
dinkelk Avatar answered Sep 30 '22 15:09

dinkelk