Programming Scripts and Functions - pbouffard/matlabtojulia GitHub Wiki
Control Flow
- if, elseif, else Execute statements if condition is true
- for for loop to repeat specified number of times
- parfor Parallel for loop
- switch, case, otherwise Execute one of several groups of statements
- try, catch Execute statements and catch resulting errors
- while while loop to repeat when condition is true
- break Terminate execution of for or while loop
- continue Pass control to next iteration of for or while loop
- end Terminate block of code, or indicate last array index
- pause Stop MATLAB execution temporarily
- return Return control to invoking function
Scripts
- edit Edit or create file
- input Request user input
- publish Generate view of MATLAB file in specified format
- grabcode Extract MATLAB code from file published to HTML
- snapnow Force snapshot of image for inclusion in published document
Functions
Function Basics
- function Declare function name, inputs, and outputs
Input and Output Arguments
Variables
Error Handling
- try, catch Execute statements and catch resulting errors
- error Throw error and display message
- warning Display warning message
- lastwarn Last warning message
- assert Throw error if condition false
- onCleanup Cleanup tasks upon function completion
Files and Folders
Search Path
- addpath Add folders to search path
- rmpath Remove folders from search path
- path View or change search path
- savepath Save current search path
- userpath View or change default user work folder
- genpath Generate path name
- pathsep Search path separator for current platform
- pathtool Open Set Path dialog box to view and change search path
- restoredefaultpath Restore search path to factory-installed state
- rehash Refresh function and file system path caches
File Operations
- dir List folder contents
- ls List folder contents
- pwd Identify current folder
- fileattrib Set or get attributes of file or folder
- exist Check existence of variable, script, function, folder, or class
- isfile Determine if input is file
- isfolder Determine if input is folder
- type Display contents of file
- visdiff Compare two files or folders
- what List MATLAB files in folder
- which Locate functions and files
- cd Change current folder
- copyfile Copy file or folder
- delete Delete files or objects
- recycle Set option to move deleted files to recycle folder
- mkdir Make new folder
- movefile Move file or folder
- rmdir Remove folder
- open Open file in appropriate application
- winopen Open file in appropriate application (Windows)
File Compression
- zip Compress files into zip file
- unzip Extract contents of zip file
- gzip Compress files into GNU zip files
- gunzip Extract contents of GNU zip file
- tar Compress files into tar file
- untar Extract contents of tar file
File Name Construction
- fileparts Get parts of file name
- fullfile Build full file name from parts
- filemarker Character to separate file name from local or nested function name
- filesep File separator for current platform
- tempdir Name of temporary folder for the system
- tempname Unique name for temporary file
- matlabroot MATLAB root folder
- toolboxdir Root folder for specified toolbox
Debugging
- dbclear Remove breakpoints
- dbcont Resume execution
- dbdown Reverse dbup workspace shift
- dbquit Quit debug mode
- dbstack Function call stack
- dbstatus List all breakpoints
- dbstep Execute next executable line from current breakpoint
- dbstop Set breakpoints for debugging
- dbtype Display file with line numbers
- dbup Shift current workspace to workspace of caller in debug mode
- keyboard Input from keyboard
- echo Display statements during function execution
Code Editor
Code Analysis and Execution
- codeCompatibilityReport Create code compatibility report
- analyzeCodeCompatibility Create code compatibility analysis results
- checkcode Check MATLAB code files for possible problems
- mlintrpt Run checkcode for file or folder
- assert Throw error if condition false
- runtests Run set of tests
- testsuite Create suite of tests
- pcode Create protected function file
- eval Execute MATLAB expression in text
- evalc Evaluate MATLAB expression with capture
- evalin Execute MATLAB expression in specified workspace
- feval Evaluate function
- run Run MATLAB script
- builtin Execute built-in function from overloaded method
- timer Create object to schedule execution of MATLAB commands