This example shows how to request specific outputs from a function.
Request all three possible outputs from the fileparts function.
helpFile = which('help'); [helpPath,name,ext] = fileparts(helpFile);
The current workspace now contains three variables from fileparts: helpPath, name, and ext. In this case, the variables are small. However, some functions return results that use much more memory. If you do not need those variables, they waste space on your system.
Request only the first output, ignoring the second and third.
helpPath = fileparts(helpFile);
For any function, you can request only the first outputs (where is less than or equal to the number of possible outputs) and ignore any remaining outputs. If you request more than one output, enclose the variable names in square brackets, .
Ignore the first output using a tilde (~).
[~,name,ext] = fileparts(helpFile);
You can ignore any number of function outputs, in any position in the argument list. Separate consecutive tildes with a comma, such as
[~,~,ext] = fileparts(helpFile);