Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Ignore Function Outputs

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);
Was this topic helpful?