0% found this document useful (0 votes)
26 views7 pages

Introduction To Programming in Matlab: Civil Engineering Department, NUCES, Lahore Pakistan

ll

Uploaded by

tooba Ishfaq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views7 pages

Introduction To Programming in Matlab: Civil Engineering Department, NUCES, Lahore Pakistan

ll

Uploaded by

tooba Ishfaq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Introduction to

Programming in
MATLAB (CL-206)

By:
Dr. Tauqir Ahmed
m-file
[email protected] use of ‘disp’ command
Topics: 18 March 2021 Week No. 2

Civil Engineering Department, NUCES, Lahore Pakistan


1
Working in Command Window of MATLAB

Working in command window Runtime results Working in

command window is useful for simple problems

However,

Work is not saved for later use.

Not easy to make changes.


NOTE:
1- For Programing in MATLAB ‘Editor
window’ is use to write and save the
program.

2- File is save as filename.m therefore


called as m-files
m-file in MATLAB
-> The extension of MATLAB files is .m therefore called as m-

files -> ‘Editor Window’ is use to create the m-files.

-> by default m-files are saved in current working directory. -> Like any

other computer files, m-files can be open/edit/save at anytime. -> To


execute m-file

Practical demonstration

Creat m-file save m-file Edit m-file.


Commands for managing the Work Session
clc Clear the command window
clear Clear all variables
clear var1, Clear selective variables
var2
format Set the format to display the significant
digits (in results)
% Comment
exist(‘var1’) To check either a variable with name var1 exist
;
or not. Suppresses screen printing
dir List the files in current directory

Practical demonstration
Use of ‘disp’ command

In MATLAB, disp command is use to display in command Window

disp(‘string’) is to display the strings

disp(var1) is to display the value of var1


Practical demonstration
Use of ‘disp’ command

To display the String and variable together is same line. First, need to
make a string by using num2str(var1)
Practical
demonstration
Concluded

You might also like