Documentation

This is machine translation

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

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

MATLAB Code Examples

Standalone Examples

A standalone example is a readable version of a MATLAB® script that shows how to accomplish a particular task. MATLAB and all MATLAB toolboxes include examples as part of the installed documentation. (Before release R2012b, these examples were called demos.)

Access examples by clicking Examples on the right or bottom left of the main documentation page for a particular product. You can also access examples by clicking the icon to the right of the product name.

MATLAB include various examples that demonstrate various functionality. For instance, click on Graphics to view examples demonstrating plotting functionality in MATLAB.

Each example combines comments, code, and output together in a formatted document. You can open the corresponding script in the Editor by clicking Open Script or Open Live Script to the right of the example name, or by clicking Open Script or Open Live Script at the top of the example page in the Help browser.

In the Editor, there are two ways to run the script:

  • Run one section at a time and view the incremental results. Select the first section, and then step through the script by clicking Run and Advance, .

  • Run the entire script by clicking Run or Run All .

Additional examples, created by members of the MATLAB community, are available at the File Exchange.

Inline Examples

The product documentation also includes inline code excerpts, such as examples on function pages like cos or plot. You can run inline code from the Help browser by selecting the code, right-clicking, and then selecting Evaluate Selection, as shown. (On Macintosh systems, press Shift+F7, which copies code to the Command Window for evaluation.)

See Also

|

Related Examples

External Websites

Was this topic helpful?