23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Operating System Compatibility<br />

Operating System Compatibility<br />

This section covers the following topics:<br />

• “Executing O/S Commands from <strong>MATLAB</strong>” on page 12-53<br />

• “Searching Text with grep” on page 12-53<br />

• “Constructing Paths and Filenames” on page 12-53<br />

• “Finding the <strong>MATLAB</strong> Root Directory” on page 12-54<br />

• “Temporary Directories and Filenames” on page 12-54<br />

Executing O/S Commands from <strong>MATLAB</strong><br />

To execute a command from your operating system prompt without having to<br />

exit <strong>MATLAB</strong>, precede the command with the <strong>MATLAB</strong> ! operator.<br />

OnWindows,youcanaddanampersand(&) totheendofthelinetomakethe<br />

output appear in a separate window.<br />

For more information: See Running External Programs in the <strong>MATLAB</strong><br />

Desktop Tools and Development Environment documentation, and the system<br />

and dos function reference pages.<br />

Searching Text with grep<br />

grep is a powerful tool for performing text searches in files on UNIX systems.<br />

To grep from within <strong>MATLAB</strong>, precede the command with an exclamation<br />

point (!grep).<br />

For example, to search for the word warning, ignoring case, in all M-files of<br />

the current directory, you would use<br />

!grep -i 'warning' *.m<br />

Constructing Paths and Filenames<br />

Use the fullfile function to construct path names and filenames rather<br />

than entering them as strings into your programs. In this way, you always<br />

get the correct path specification, regardless of which operating system you<br />

areusingatthetime.<br />

12-53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!