SlideShare a Scribd company logo
1 of 2
Download to read offline
http://www.tutorialspoint.com/matlab/matlab_m_files.htm Copyright © tutorialspoint.com
MATLAB M-FILES
So far, we have used MATLAB environment as a calculator. However, MATLAB is also a powerfulprogramming
language, as wellas aninteractive computationalenvironment.
Inprevious chapters, youhave learned how to enter commands fromthe MATLAB command prompt. MATLAB
also allows youto write series of commands into a file and execute the file as complete unit, like writing a function
and calling it.
The M Files
MATLAB allows writing two kinds of programfiles:
Scripts - script files are programfiles with.m extension. Inthese files, youwrite series of commands,
whichyouwant to execute together. Scripts do not accept inputs and do not returnany outputs. They
operate ondata inthe workspace.
Functions - functions files are also programfiles with.m extension. Functions canaccept inputs and
returnoutputs. Internalvariables are localto the function.
Youcanuse the MATLAB Editor or any other text editor to create your .mfiles. Inthis section, we willdiscuss
the script files. A script file contains multiple sequentiallines of MATLAB commands and functioncalls. Youcan
runa script by typing its name at the command line.
Creating and Running Script File
To create scripts files, youneed to use a text editor. Youcanopenthe MATLAB editor intwo ways:
Using the command prompt
Using the IDE
If youare using the command prompt, type edit inthe command prompt. This willopenthe editor. Youcan
directly type edit and thenthe filename (with.mextension)
edit
Or
edit <filename>
The above command willcreate the file indefault MATLAB directory. If youwant to store allprogramfiles ina
specific folder, thenyouwillhave to provide the entire path.
Let us create a folder named progs. Type the following commands at the command prompt(>>):
mkdir progs % create directory progs under default directory
chdir progs % changing the current directory to progs
edit prog1.m % creating an m file named prog1.m
If youare creating the file for first time, MATLAB prompts youto confirmit. Click Yes.
Alternatively, if youare using the IDE, choose NEW -> Script. This also opens the editor and creates a file
named Untitled. Youcanname and save the file after typing the code.
Type the following code inthe editor:
NoOfStudents = 6000;
TeachingStaff = 150;
NonTeachingStaff = 20;
Total = NoOfStudents + TeachingStaff ...
+ NonTeachingStaff;
disp(Total);
After creating and saving the file, youcanrunit intwo ways:
Clicking the Run buttononthe editor window or
Just typing the filename (without extension) inthe command prompt: >> prog1
The command window prompt displays the result:
6170
Example
Create a script file, and type the following code:
a = 5; b = 7;
c = a + b
d = c + sin(b)
e = 5 * d
f = exp(-d)
Whenthe above code is compiled and executed, it produces the following result:
c =
12
d =
12.6570
e =
63.2849
f =
3.1852e-06

More Related Content

What's hot

postgres loader
postgres loaderpostgres loader
postgres loaderINRIA-OAK
 
M5 l7-rails controllers-response-handout
M5 l7-rails controllers-response-handoutM5 l7-rails controllers-response-handout
M5 l7-rails controllers-response-handoutNolboo Kim
 
Pluggable Pipelines
Pluggable PipelinesPluggable Pipelines
Pluggable Pipelinessetitesuk
 
Batch job processing
Batch job processingBatch job processing
Batch job processingSon Nguyen
 

What's hot (8)

postgres loader
postgres loaderpostgres loader
postgres loader
 
M5 l7-rails controllers-response-handout
M5 l7-rails controllers-response-handoutM5 l7-rails controllers-response-handout
M5 l7-rails controllers-response-handout
 
cpp-file-handling
cpp-file-handlingcpp-file-handling
cpp-file-handling
 
Pluggable Pipelines
Pluggable PipelinesPluggable Pipelines
Pluggable Pipelines
 
M batching
M batchingM batching
M batching
 
Mule batch
Mule batchMule batch
Mule batch
 
Mule batch processing
Mule batch processingMule batch processing
Mule batch processing
 
Batch job processing
Batch job processingBatch job processing
Batch job processing
 

Viewers also liked

Matlab: Procedures And Functions
Matlab: Procedures And FunctionsMatlab: Procedures And Functions
Matlab: Procedures And Functionsmatlab Content
 
Matlab m files and scripts
Matlab m files and scriptsMatlab m files and scripts
Matlab m files and scriptsAmeen San
 
Driving Greater CRM Productivity with M-Files Solution for Law Firms
Driving Greater CRM Productivity with M-Files Solution for Law FirmsDriving Greater CRM Productivity with M-Files Solution for Law Firms
Driving Greater CRM Productivity with M-Files Solution for Law FirmsArtem Shpachenko
 
Algoritma Rinaldi Munir
Algoritma Rinaldi MunirAlgoritma Rinaldi Munir
Algoritma Rinaldi MunirTeguh Wiryanto
 
Simulating communication systems with MATLAB: An introduction
Simulating communication systems with MATLAB: An introductionSimulating communication systems with MATLAB: An introduction
Simulating communication systems with MATLAB: An introductionAniruddha Chandra
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to MatlabAmr Rashed
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introductionideas2ignite
 
Simulation of Wireless Communication Systems
Simulation of Wireless Communication SystemsSimulation of Wireless Communication Systems
Simulation of Wireless Communication SystemsBernd-Peter Paris
 

Viewers also liked (14)

Matlab Text Files
Matlab Text FilesMatlab Text Files
Matlab Text Files
 
Matlab: Procedures And Functions
Matlab: Procedures And FunctionsMatlab: Procedures And Functions
Matlab: Procedures And Functions
 
147994600 transformada-de-fourier
147994600 transformada-de-fourier147994600 transformada-de-fourier
147994600 transformada-de-fourier
 
matab no2
matab no2matab no2
matab no2
 
Matlab m files and scripts
Matlab m files and scriptsMatlab m files and scripts
Matlab m files and scripts
 
Driving Greater CRM Productivity with M-Files Solution for Law Firms
Driving Greater CRM Productivity with M-Files Solution for Law FirmsDriving Greater CRM Productivity with M-Files Solution for Law Firms
Driving Greater CRM Productivity with M-Files Solution for Law Firms
 
Algoritma Rinaldi Munir
Algoritma Rinaldi MunirAlgoritma Rinaldi Munir
Algoritma Rinaldi Munir
 
Mk ed4 ekf
Mk ed4 ekfMk ed4 ekf
Mk ed4 ekf
 
[EN] ECM: Whithersoever | Keynote by Ulrich Kampffmeyer @ M-Files EMEA Partne...
[EN] ECM: Whithersoever | Keynote by Ulrich Kampffmeyer @ M-Files EMEA Partne...[EN] ECM: Whithersoever | Keynote by Ulrich Kampffmeyer @ M-Files EMEA Partne...
[EN] ECM: Whithersoever | Keynote by Ulrich Kampffmeyer @ M-Files EMEA Partne...
 
Matlab Basic Tutorial
Matlab Basic TutorialMatlab Basic Tutorial
Matlab Basic Tutorial
 
Simulating communication systems with MATLAB: An introduction
Simulating communication systems with MATLAB: An introductionSimulating communication systems with MATLAB: An introduction
Simulating communication systems with MATLAB: An introduction
 
Introduction to Matlab
Introduction to MatlabIntroduction to Matlab
Introduction to Matlab
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
Simulation of Wireless Communication Systems
Simulation of Wireless Communication SystemsSimulation of Wireless Communication Systems
Simulation of Wireless Communication Systems
 

Similar to Matlab m files

Introduction to Matlab Scripts
Introduction to Matlab ScriptsIntroduction to Matlab Scripts
Introduction to Matlab ScriptsShameer Ahmed Koya
 
CSO Laboratory Manual
CSO Laboratory ManualCSO Laboratory Manual
CSO Laboratory ManualDwight Sabio
 
help with Linux/Unix starting
help with Linux/Unix startinghelp with Linux/Unix starting
help with Linux/Unix startingdummy
 
Introduction to MATLAB 2
Introduction to MATLAB 2Introduction to MATLAB 2
Introduction to MATLAB 2Mohamed Gafar
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab IntroductionDaniel Moore
 
MATLAB Program Example Research Help
MATLAB Program Example Research HelpMATLAB Program Example Research Help
MATLAB Program Example Research HelpMatlab Simulation
 
Matlab - Introduction and Basics
Matlab - Introduction and BasicsMatlab - Introduction and Basics
Matlab - Introduction and BasicsTechsparks
 
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docxLab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docxDIPESH30
 
Dumping and Cracking SAM Hashes to Extract Plaintext Passwords
Dumping and Cracking SAM Hashes to Extract Plaintext PasswordsDumping and Cracking SAM Hashes to Extract Plaintext Passwords
Dumping and Cracking SAM Hashes to Extract Plaintext PasswordsVishal Kumar
 
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul Divyanshu
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2Dr.Ravi
 
fileop report
fileop reportfileop report
fileop reportJason Lu
 

Similar to Matlab m files (20)

Introduction to Matlab Scripts
Introduction to Matlab ScriptsIntroduction to Matlab Scripts
Introduction to Matlab Scripts
 
Mat-lab image processing tatorial
Mat-lab  image processing tatorialMat-lab  image processing tatorial
Mat-lab image processing tatorial
 
CSO Laboratory Manual
CSO Laboratory ManualCSO Laboratory Manual
CSO Laboratory Manual
 
help with Linux/Unix starting
help with Linux/Unix startinghelp with Linux/Unix starting
help with Linux/Unix starting
 
Introduction to MATLAB 2
Introduction to MATLAB 2Introduction to MATLAB 2
Introduction to MATLAB 2
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
File handling
File handlingFile handling
File handling
 
Install
InstallInstall
Install
 
Matlab Introduction
Matlab IntroductionMatlab Introduction
Matlab Introduction
 
MATLAB Program Example Research Help
MATLAB Program Example Research HelpMATLAB Program Example Research Help
MATLAB Program Example Research Help
 
Matlab - Introduction and Basics
Matlab - Introduction and BasicsMatlab - Introduction and Basics
Matlab - Introduction and Basics
 
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docxLab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docx
 
A05
A05A05
A05
 
Mbuild help
Mbuild helpMbuild help
Mbuild help
 
Dumping and Cracking SAM Hashes to Extract Plaintext Passwords
Dumping and Cracking SAM Hashes to Extract Plaintext PasswordsDumping and Cracking SAM Hashes to Extract Plaintext Passwords
Dumping and Cracking SAM Hashes to Extract Plaintext Passwords
 
Vipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentationVipul divyanshu mahout_documentation
Vipul divyanshu mahout_documentation
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
 
Linux intro 5 extra: makefiles
Linux intro 5 extra: makefilesLinux intro 5 extra: makefiles
Linux intro 5 extra: makefiles
 
Lab 1 Essay
Lab 1 EssayLab 1 Essay
Lab 1 Essay
 
fileop report
fileop reportfileop report
fileop report
 

More from pramodkumar1804 (20)

Matlab syntax
Matlab syntaxMatlab syntax
Matlab syntax
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
 
Matlab simulink
Matlab simulinkMatlab simulink
Matlab simulink
 
Matlab polynomials
Matlab polynomialsMatlab polynomials
Matlab polynomials
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Matlab overview 3
Matlab overview 3Matlab overview 3
Matlab overview 3
 
Matlab overview 2
Matlab overview 2Matlab overview 2
Matlab overview 2
 
Matlab overview
Matlab overviewMatlab overview
Matlab overview
 
Matlab operators
Matlab operatorsMatlab operators
Matlab operators
 
Matlab variables
Matlab variablesMatlab variables
Matlab variables
 
Matlab numbers
Matlab numbersMatlab numbers
Matlab numbers
 
Matlab matrics
Matlab matricsMatlab matrics
Matlab matrics
 
Matlab loops 2
Matlab loops 2Matlab loops 2
Matlab loops 2
 
Matlab loops
Matlab loopsMatlab loops
Matlab loops
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
 
Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
 
Matlab gnu octave
Matlab gnu octaveMatlab gnu octave
Matlab gnu octave
 
Matlab operators
Matlab operatorsMatlab operators
Matlab operators
 
Matlab functions
Matlab functionsMatlab functions
Matlab functions
 
Matlab differential
Matlab differentialMatlab differential
Matlab differential
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Matlab m files

  • 1. http://www.tutorialspoint.com/matlab/matlab_m_files.htm Copyright © tutorialspoint.com MATLAB M-FILES So far, we have used MATLAB environment as a calculator. However, MATLAB is also a powerfulprogramming language, as wellas aninteractive computationalenvironment. Inprevious chapters, youhave learned how to enter commands fromthe MATLAB command prompt. MATLAB also allows youto write series of commands into a file and execute the file as complete unit, like writing a function and calling it. The M Files MATLAB allows writing two kinds of programfiles: Scripts - script files are programfiles with.m extension. Inthese files, youwrite series of commands, whichyouwant to execute together. Scripts do not accept inputs and do not returnany outputs. They operate ondata inthe workspace. Functions - functions files are also programfiles with.m extension. Functions canaccept inputs and returnoutputs. Internalvariables are localto the function. Youcanuse the MATLAB Editor or any other text editor to create your .mfiles. Inthis section, we willdiscuss the script files. A script file contains multiple sequentiallines of MATLAB commands and functioncalls. Youcan runa script by typing its name at the command line. Creating and Running Script File To create scripts files, youneed to use a text editor. Youcanopenthe MATLAB editor intwo ways: Using the command prompt Using the IDE If youare using the command prompt, type edit inthe command prompt. This willopenthe editor. Youcan directly type edit and thenthe filename (with.mextension) edit Or edit <filename> The above command willcreate the file indefault MATLAB directory. If youwant to store allprogramfiles ina specific folder, thenyouwillhave to provide the entire path. Let us create a folder named progs. Type the following commands at the command prompt(>>): mkdir progs % create directory progs under default directory chdir progs % changing the current directory to progs edit prog1.m % creating an m file named prog1.m If youare creating the file for first time, MATLAB prompts youto confirmit. Click Yes.
  • 2. Alternatively, if youare using the IDE, choose NEW -> Script. This also opens the editor and creates a file named Untitled. Youcanname and save the file after typing the code. Type the following code inthe editor: NoOfStudents = 6000; TeachingStaff = 150; NonTeachingStaff = 20; Total = NoOfStudents + TeachingStaff ... + NonTeachingStaff; disp(Total); After creating and saving the file, youcanrunit intwo ways: Clicking the Run buttononthe editor window or Just typing the filename (without extension) inthe command prompt: >> prog1 The command window prompt displays the result: 6170 Example Create a script file, and type the following code: a = 5; b = 7; c = a + b d = c + sin(b) e = 5 * d f = exp(-d) Whenthe above code is compiled and executed, it produces the following result: c = 12 d = 12.6570 e = 63.2849 f = 3.1852e-06