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?
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.
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 .
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.
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 .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With