The document discusses how to create, save, open and modify script files in MATLAB. It explains how to write commands in a script file, save it with a .m extension, execute the file, and edit an existing script file to add user input and draw a circle with a radius entered by the user.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
33 views13 pages
Matlab Lecture 6
The document discusses how to create, save, open and modify script files in MATLAB. It explains how to write commands in a script file, save it with a .m extension, execute the file, and edit an existing script file to add user input and draw a circle with a radius entered by the user.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13
Creating, Saving and Executing a Script File
• A script file is a user created file with a sequence of matlab commands in
it. The file must be saved with a ‘.m’ extension to its name, thereby, making it an M-file. A script file is executed by typing its name (without the ‘.m’ extension at the command prompt. What do we learn here • How to create, write and save a script file. • How to execute the script file in MATLAB. • How to use the built-in MATLAB editor on a PC. • How to open, edit and save a file • In which directory your file is saved in. How to open the MATLAB editor
Click the above encircled icon
MATLAB editor will be opened • Type the following lines: • After writing these lines we have to save this file Modify the script file aks.m to draw a circle of arbitrary radius r as follows: • Include the following command in the script file before the first executable line to ask the user to input(r) on the screen : r=input(‘Enter the radius of the circle: ‘) • Modify the x and y coordinate calculations appropriately . • Save and execute the file. When asked, enter a value for the radius and press return. Modify the script file aks.m to show the center of the circle on the plot, too. Show the center point with a ‘+’. 𝑥 = 𝑥𝑐 +𝑟 cos 𝜃