How to create Script files in MATLAB

How to create Script files in MATLAB

In MATLAB, we have command window, in which we type command and press enter to execute. If you want to write command in MATLAB you have to write all commands in sequence and have to press enter after every line. So, it is not convenient way to write a program in MATLAB.

MATLAB provides a better way to execute set of commands, by creating a script file. In script file you have to list all commands in it, save it and execute file. When the file runs, commands are executed in the order as they are listed in the file. If needed, the commands in file can be changed and then file can be saved and run again with updated commands.

Conventions

  • Script file is sequence of commands, can be called program.
  • If script file contains command that generates an output, output will be displayed in command window
  • Script files are also called M-files because files are saved with .m extension

Create a script file in MATLAB

Script files are created in Debugger window.

  • In File menu, select New and then select Script
  • Script file can be opened with shortcut key Ctrl + N

Follow tutorial for creating and executing files.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s