SlideShare a Scribd company logo
1 of 52
INTRODUCTION
to
MATLAB
By: Prof. Ganesh Ingle
Session objective
COMPUTERS AND PROGRAMMING
PROGRAMMING LANGUAGES TYPES
MATLAB INTRODUCTION
IDE ,COMMANDS ,RESULTS ,M FILE
COMPARE A SAMPLE CODE IN C WITH MATLAB
SUMMARY
Computers and Programming
1. Computer: An electronic device which
is capable of performing complex
arithmetical and logical operations to
get the desired result
2. Program: Set of instructions given to
the computer to execute a particular
task.
Programming Languages Types
1. Machine level language
2. Assembly level language (Assembler)
3. High level language (Compiler interpreter)
MATLAB Introduction
1. What is MATLAB ???
2. Why MATALB???
a. Interfacing API for
TMS320(DSP),ARM,89s51,89s52,…..
b. Port interfacing
c. Reduces time required for PDLC
d. Scientific calculations
MATLAB Applications
1. Communication engineering
2. AI,ML,DL
3. Image processing
4. Optimization
5. Data access ,analysis and visualization
6. Programming and algorithm designing
7. Performance analysis of algorithms
8. Simulink
MATLAB Commands
1. date
2. clock
3. ver
4. whos
5. what(files in current dir)
6. clc
7. clear
8. diary filename
9. diary off
10. diary on
11. path
12. editpath GUI ,home,set path
13.! DOS command
14. exit
MATLAB Operators/Symbols/Functions
1. +
2. -
3. *
4. /
5. ^
6. =
7. ==
8. pi
9. vpa (digit precision)
10. %
11. ;
12. : range
13.randn() %10,
1:1:10;
14. Ctrl+c
15. ceil
16. floor
17. sqrt
18. Matrix (+,-,*)
19. ‘.’ operator
20. eye
21. zeros(5)
22. ` transpose
23. ones(6)
MATLAB Operators/Symbols/Functions
24. imread()
25. imshow
26. disp()
27. input()
28. factorial()
29. length(a)
30. size(a)
31. fprintf()-only o/p
32. sprintf()-o/p with save in workspace
33. format rat/ long /hex /shortEng/logEng
34. de2bi, d=(1:10)’; b=de2bi(d); [d,b]
35. decimalToBinaryVector(x);MSB,LSB
MATLAB Operators/Symbols/Functions
36. All trigonometric values and error o/p
37. cosd(),sind()
38. All hyperbolic trigonometric values
39. mod(x,y)
40. log(x) %natural log
41. log10(x)
MATLAB Variables and Data Types
Data types
Logical Char Numeric
Int 8 unint 8
Int 16 unint 16
Int 32 unint 32
Int 64 unint 64
Single Double
Structure Function Handle
Typing Mathematical Expression
1)
R1=
−𝑏+ 𝑏2−4𝑎𝑐
2𝑎
R2=
−𝑏± 𝑏
2
−4𝑎𝑐
2𝑎
2)
R1= 𝑎2 + 𝑏2
e-0.2t cos 2t
3)
E=mc2
Y=1 +
𝑛𝑥
1!
+
𝑛 𝑛−1 𝑥2
2!
MATLAB Code File
1. File name should not start with number
2. No Space in the file name
3. No library function name
4. No use of keywords reserved by MATALAB
MATLAB Searching Mechanism
1. Workspace
2. Current directory
3. Set path directory
Compare code in C with MATLAB
1. WAP program to perform addition of two
numbers a and b with following constraint:
 Do not use + operator i.e. c=a+b
 Do not use –(-) operator i.e. c=a-(-b)
 Do not use x(-1) i.e. c=a-b(-1)
 Do not use c=b-(-a)
 Do not c=b-(-a)
 Do not use c=a-
𝟏
𝟏
−𝒃
 Do not use c=b-
𝟏
𝟏
−𝒂
 Do not use c=
𝒂 𝟐−𝒃 𝟐
𝒂−𝒃
Objectives:
1. Find the solution and
logic
2. Compare C and Matlab
code
MATLAB Programming Exercise
1. WAP to find the roots of the quadratic
equations
2. Ideal gas law problem to find volume
3. Let us see direct implementation using
MATLAB………..
THANK YOU
Image Source
searchenterpriseai.techtarget.com
wikipedia
Matlab Commands
With Example
%Matrix computations and operations
>> %creating vectors and matrices
>> %create a row vector, we can form a row vector.
>> a=[1 3 6 8];
>> a
a =
1 3 6 8
MATLAB Command With Syntax
>> %create a column vector,
>> b=[1;4;6;10];
>> b
b =
1
4
6
10
MATLAB Command With Syntax
>>Create the matrix x of 3 rows and 4 columns
x=[12 23 21 3; 2 34 5 7; 31 32 33 34];
>> x
x =
12 23 21 3
2 34 5 7
31 32 33 34
MATLAB Command With Syntax
%elements of a Matrix
>> z=x(2,3)
z = 5
>> x1=x(1,:)
x1 = 12 23 21 3
>> x2=x(:,2)
x2 =
23
34
32
>> s=size(x)
s = 3 4
MATLAB Command With Syntax
Remove the n th
X(n, : ) = [ ]
x(2, : ) = [ ]
Add a column of 4,s to the end of matrix.
x( ; , 4) = 4
MATLAB Command With Syntax
We can extend the colon notation to specify a
sequence
Create a vector v which starts at 1, with increment
of 2 and stops at 10:
v=1:2:10
v = 1 3 5 7 9
>> v=1:10
v = 1 2 3 4 5 6 7 8 9 10
MATLAB Command With Syntax
x=[11 12 13 14; 21 22 23 24;31 32 33 34];
>> x
x =
11 12 13 14
21 22 23 24
31 32 33 34
We can use this vector notation when
referring to sub matrix:
w=x(1:2:3, 2:4)
MATLAB Command With Syntax
w =
12 13 14
32 33 34
Rows :start at 1, increment by 2, stop at 3
Columns 2,3,4start at 2, stop at 4 default
increment of 1 is used
MATLAB Command With Syntax
x=[11 12 13 14;21 22 23 24 ;31 32 33 34 ]
x =
11 12 13 14
21 22 23 24
31 32 33 34
>> x4=x(1:2:3,2:4)
x4 =
12 13 14
32 33 34
MATLAB Command With Syntax
x4=x(1:2:2,2:4)
x4 =
12 13 14
>> x4=x(1:1:3,2:4)
x4 =
12 13 14
22 23 24
32 33 34
MATLAB Command With Syntax
x4=x(1:1:2,2:4)
x4 =
12 13 14
22 23 24
x4=[x;41 42 43 44]
x4 =
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
x= [41 42 43 44;x] ?
MATLAB Command With Syntax
x4 = x(2:1:3,2:4)
x4 =
22 23 24
32 33 34
x(4 , : ) = [41 42 43 44]
x =
11 12 13 14
21 22 23 24
31 32 33 34
41 42 43 44
MATLAB Command With Syntax
x4=x(1:1:2,1:4)
x4 =
11 12 13 14
21 22 23 24
>> x4=x(1:1:2,2:4)
x4 =
12 13 14
22 23 24
>> x4=x(1:1:2,3:4)
x4 =
13 14
23 24
MATLAB Command With Syntax
Strings
String handling
Syntax
S = 'Any Characters'
S = [S1 S2 ...]
S = strcat(S1, S2, ...)
MATLAB Command With Syntax
Examples
Create a simple string that includes a single quote.
msg = 'You''re right!'
msg =
You're right!
Create the string name using two methods of
concatenation.
name = ['Thomas' ' R. ' 'Lee']
name = strcat('Thomas',' R.',' Lee')
MATLAB Command With Syntax
Create a vertical array of strings.
C = strvcat('Hello','Yes','No','Goodbye‘)
C =
Hello
Yes
No
Goodbye
MATLAB Command With Syntax
S = {'Hello' 'Yes' 'No' 'Goodbye'}
S =
'Hello' 'Yes' 'No' 'Goodbye'
Create a cell array of strings.
S = {'Hello' 'Yes' 'No' 'Goodbye}
MATLAB Command With Syntax
1. Commands for Managing a Session
2. MATLAB provides various commands for managing a session.
3. The following table provides all such commands −
4. I have forgotten the Variables!
5. The who command displays all the variable names you have
used.
6. who
7. MATLAB will execute the above statement and return the
following result
MATLAB Command With Syntax
>> who
Your variables are:
a b x
>> whos
Name Size Bytes Class Attributes
a 1x4 32 double
b 4x1 32 double
x 3x4 96 double
MATLAB Command With Syntax
whos
Name Size Bytes Class Attributes
a 1x4 32 double
b 4x1 32 double
x 3x4 96 double
MATLAB Command With Syntax
Basic Task: Plot the function sin(x) between 0≤x≤4π
 Create an x-array of 100 samples between 0 and 4π.
 Calculate sin(.) of the x-array
 Plot the y-array
>>x=linspace(0,4*pi,100);
>>y=sin(x);
>>plot(y)
0 10 20 30 40 50 60 70 80 90 100
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
MATLAB Command With Syntax
Plot the function e-x/3sin(x) between 0≤x≤4π
 Create an x-array of 100 samples between 0 and 4π.
 Calculate sin(.) of the x-array
 Calculate e-x/3 of the x-array
 Multiply the arrays y and y1
>>x=linspace(0,4*pi,100);
>>y=sin(x);
>>y1=exp(-x/3);
>>y2=y.*y1;
MATLAB Command With Syntax
Plot the function e-x/3sin(x) between 0≤x≤4π
 Multiply the arrays y and y1 correctly
 Plot the y2-array
>>y2=y.*y1;
>>plot(y2)
0 10 20 30 40 50 60 70 80 90 100
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
MATLAB Command With Syntax
Display Facilities
 plot(.)
 stem(.)
Example:
>>x=linspace(0,4*pi,100);
>>y=sin(x);
>>plot(y)
>>plot(x,y)
Example:
>>stem(y)
>>stem(x,y)
0 10 20 30 40 50 60 70 80 90 100
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0 10 20 30 40 50 60 70 80 90 100
-0.3
-0.2
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
MATLAB Command With Syntax
Display Facilities
 title(.)
 xlabel(.)
 ylabel(.)
>>title(‘This is the sinus function’)
>>xlabel(‘x (secs)’)
>>ylabel(‘sin(x)’)
0 10 20 30 40 50 60 70 80 90 100
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
This is the sinus function
x (secs)
sin(x)
MATLAB Command With Syntax
Operators (relational, logical)
 == Equal to
 ~= Not equal to
 < Strictly smaller
 > Strictly greater
 <= Smaller than or equal to
 >= Greater than equal to
 & And operator
 | Or operator
 ~ NOT
MATLAB Command With Syntax
Name Meaning
ans Most recent answer.
eps Accuracy of floating-point precision.
i,j The imaginary unit √-1.
Inf Infinity.
NaN Undefined numerical result (not a
number).
pi The number π
Special Variables and Constants
MATLAB supports the following special variables and constants:
MATLAB Command With Syntax
Multiple Assignments
You can have multiple assignments on the same
line.
For example,
a = 2; b = 7; c = a * b
MATLAB will execute the above statement and
return the following result −
c = 14
MATLAB Command With Syntax
The clear command deletes all (or the specified)
variable(s) from the memory.
clear x % it will delete x, won't display anything
clear % it will delete all variables in the
% workspace
% peacefully and unobtrusively
MATLAB Command With Syntax
Command Purpose
clc Clears command window.
clear Removes variables from memory.
exist Checks for existence of file or variable.
global Declares variables to be global.
help Searches for a help topic.
lookfor Searches help entries for a keyword.
quit Stops MATLAB.
who Lists current variables.
whos Lists current variables (long display).
Commands for Managing a Session
MATLAB provides various commands for managing a session.
The following table provides all such commands −
MATLAB Command With Syntax
MATLAB provides various useful commands for
working with the system, like saving the current work
in the workspace as a file and loading the file later.
It also provides various commands for other system-
related activities like, displaying date, listing files in
the directory, displaying current directory, etc.
MATLAB Command With Syntax
Command Purpose
cd Changes current directory.
date Displays current date.
delete Deletes a file.
diary Switches on/off diary file recording
Commands for Working with the System
The following table displays some commonly used system-related commands −
MATLAB Command With Syntax
Command Purpose
disp Displays contents of an array or string.
fscanf Read formatted data from a file.
format Controls screen-display format.
fprintf Performs formatted writes to screen or file.
input Displays prompts and waits for input.
; Suppresses screen printing.
Input and Output Commands
MATLAB provides the following
Input and output related commands −
MATLAB Command With Syntax
Assignments
1. Create a matrix A of zeros [2x4], and B of ones[2x3].
i. Add A by 2 to create matrix of twos.
ii. Can we add A+B? and A-B? justify your Answer.
2. Create matrix of 4 rows and 3 columns.
i. Add X by 4 to create new matrix called Y.
ii. Form C= X+Y
iii. Form D= X-Y
iv. Remove second row.
v. Add a column of 4’s to the end of matrix.
3. Using matrix operations to solve the following system of linear equations.
4x - 2y + 6z = 8
2x + 8y + 2z = 4
6x +10y +3z = 0.
MATLAB Command With Syntax
THANK YOU
Image Source
searchenterpriseai.techtarget.com
wikipedia

More Related Content

What's hot

Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Randa Elanwar
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programmingRanjan Pal
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Randa Elanwar
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks QueuesIntro C# Book
 
Matlab programming project
Matlab programming projectMatlab programming project
Matlab programming projectAssignmentpedia
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programmingDamian T. Gordon
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab FunctionsUmer Azeem
 
Sample presentation slides template
Sample presentation slides templateSample presentation slides template
Sample presentation slides templateValerii Klymchuk
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab OverviiewNazim Naeem
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
Introduction to Recursion (Python)
Introduction to Recursion (Python)Introduction to Recursion (Python)
Introduction to Recursion (Python)Thai Pangsakulyanont
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]MomenMostafa
 

What's hot (20)

Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4
 
Basics of MATLAB programming
Basics of MATLAB programmingBasics of MATLAB programming
Basics of MATLAB programming
 
Matlab1
Matlab1Matlab1
Matlab1
 
Lectue five
Lectue fiveLectue five
Lectue five
 
Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4Introduction to matlab lecture 2 of 4
Introduction to matlab lecture 2 of 4
 
Matlab Tutorial
Matlab TutorialMatlab Tutorial
Matlab Tutorial
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
 
Matlab programming project
Matlab programming projectMatlab programming project
Matlab programming project
 
Introduction to MatLab programming
Introduction to MatLab programmingIntroduction to MatLab programming
Introduction to MatLab programming
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Matlab Functions
Matlab FunctionsMatlab Functions
Matlab Functions
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Sample presentation slides template
Sample presentation slides templateSample presentation slides template
Sample presentation slides template
 
Matlab commands
Matlab commandsMatlab commands
Matlab commands
 
Matlab Overviiew
Matlab OverviiewMatlab Overviiew
Matlab Overviiew
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
Introduction to Recursion (Python)
Introduction to Recursion (Python)Introduction to Recursion (Python)
Introduction to Recursion (Python)
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
Computational Assignment Help
Computational Assignment HelpComputational Assignment Help
Computational Assignment Help
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
 

Similar to Programming with matlab session 1

MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkreddyprasad reddyvari
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.pptkebeAman
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabBilawalBaloch1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabDnyanesh Patil
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptximman gwu
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 introRagu Nathan
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsMukesh Kumar
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxgilpinleeanna
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxandreecapon
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdfssuser43b38e
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 

Similar to Programming with matlab session 1 (20)

MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkMATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulink
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
Es272 ch1
Es272 ch1Es272 ch1
Es272 ch1
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 intro
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Introduction to Matlab.pdf
Introduction to Matlab.pdfIntroduction to Matlab.pdf
Introduction to Matlab.pdf
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Matlab
MatlabMatlab
Matlab
 
MATLAB Programming
MATLAB Programming MATLAB Programming
MATLAB Programming
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 

More from Infinity Tech Solutions

Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5Infinity Tech Solutions
 
Main topic 3 problem solving and office automation
Main topic 3 problem solving and office automationMain topic 3 problem solving and office automation
Main topic 3 problem solving and office automationInfinity Tech Solutions
 
Computer memory, Types of programming languages
Computer memory, Types of programming languagesComputer memory, Types of programming languages
Computer memory, Types of programming languagesInfinity Tech Solutions
 
AI/ML/DL/BCT A Revolution in Maritime Sector
AI/ML/DL/BCT A Revolution in Maritime SectorAI/ML/DL/BCT A Revolution in Maritime Sector
AI/ML/DL/BCT A Revolution in Maritime SectorInfinity Tech Solutions
 
Programming with matlab session 5 looping
Programming with matlab session 5 loopingProgramming with matlab session 5 looping
Programming with matlab session 5 loopingInfinity Tech Solutions
 

More from Infinity Tech Solutions (20)

Database management system session 6
Database management system session 6Database management system session 6
Database management system session 6
 
Database management system session 5
Database management system session 5Database management system session 5
Database management system session 5
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
 
Database Management System-session1-2
Database Management System-session1-2Database Management System-session1-2
Database Management System-session1-2
 
Main topic 3 problem solving and office automation
Main topic 3 problem solving and office automationMain topic 3 problem solving and office automation
Main topic 3 problem solving and office automation
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
E commerce
E commerce E commerce
E commerce
 
E commerce
E commerceE commerce
E commerce
 
Bds session 13 14
Bds session 13 14Bds session 13 14
Bds session 13 14
 
Computer memory, Types of programming languages
Computer memory, Types of programming languagesComputer memory, Types of programming languages
Computer memory, Types of programming languages
 
Basic hardware familiarization
Basic hardware familiarizationBasic hardware familiarization
Basic hardware familiarization
 
User defined functions in matlab
User defined functions in  matlabUser defined functions in  matlab
User defined functions in matlab
 
Programming with matlab session 3 notes
Programming with matlab session 3 notesProgramming with matlab session 3 notes
Programming with matlab session 3 notes
 
AI/ML/DL/BCT A Revolution in Maritime Sector
AI/ML/DL/BCT A Revolution in Maritime SectorAI/ML/DL/BCT A Revolution in Maritime Sector
AI/ML/DL/BCT A Revolution in Maritime Sector
 
Programming with matlab session 5 looping
Programming with matlab session 5 loopingProgramming with matlab session 5 looping
Programming with matlab session 5 looping
 
BIG DATA Session 7 8
BIG DATA Session 7 8BIG DATA Session 7 8
BIG DATA Session 7 8
 
BIG DATA Session 6
BIG DATA Session 6BIG DATA Session 6
BIG DATA Session 6
 
MS word
MS word MS word
MS word
 
DBMS CS 4-5
DBMS CS 4-5DBMS CS 4-5
DBMS CS 4-5
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 

Recently uploaded

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 

Programming with matlab session 1

  • 2. Session objective COMPUTERS AND PROGRAMMING PROGRAMMING LANGUAGES TYPES MATLAB INTRODUCTION IDE ,COMMANDS ,RESULTS ,M FILE COMPARE A SAMPLE CODE IN C WITH MATLAB SUMMARY
  • 3. Computers and Programming 1. Computer: An electronic device which is capable of performing complex arithmetical and logical operations to get the desired result 2. Program: Set of instructions given to the computer to execute a particular task.
  • 4. Programming Languages Types 1. Machine level language 2. Assembly level language (Assembler) 3. High level language (Compiler interpreter)
  • 5. MATLAB Introduction 1. What is MATLAB ??? 2. Why MATALB??? a. Interfacing API for TMS320(DSP),ARM,89s51,89s52,….. b. Port interfacing c. Reduces time required for PDLC d. Scientific calculations
  • 6. MATLAB Applications 1. Communication engineering 2. AI,ML,DL 3. Image processing 4. Optimization 5. Data access ,analysis and visualization 6. Programming and algorithm designing 7. Performance analysis of algorithms 8. Simulink
  • 7. MATLAB Commands 1. date 2. clock 3. ver 4. whos 5. what(files in current dir) 6. clc 7. clear 8. diary filename 9. diary off 10. diary on 11. path 12. editpath GUI ,home,set path 13.! DOS command 14. exit
  • 8. MATLAB Operators/Symbols/Functions 1. + 2. - 3. * 4. / 5. ^ 6. = 7. == 8. pi 9. vpa (digit precision) 10. % 11. ; 12. : range 13.randn() %10, 1:1:10; 14. Ctrl+c 15. ceil 16. floor 17. sqrt 18. Matrix (+,-,*) 19. ‘.’ operator 20. eye 21. zeros(5) 22. ` transpose 23. ones(6)
  • 9. MATLAB Operators/Symbols/Functions 24. imread() 25. imshow 26. disp() 27. input() 28. factorial() 29. length(a) 30. size(a) 31. fprintf()-only o/p 32. sprintf()-o/p with save in workspace 33. format rat/ long /hex /shortEng/logEng 34. de2bi, d=(1:10)’; b=de2bi(d); [d,b] 35. decimalToBinaryVector(x);MSB,LSB
  • 10. MATLAB Operators/Symbols/Functions 36. All trigonometric values and error o/p 37. cosd(),sind() 38. All hyperbolic trigonometric values 39. mod(x,y) 40. log(x) %natural log 41. log10(x)
  • 11. MATLAB Variables and Data Types Data types Logical Char Numeric Int 8 unint 8 Int 16 unint 16 Int 32 unint 32 Int 64 unint 64 Single Double Structure Function Handle
  • 12. Typing Mathematical Expression 1) R1= −𝑏+ 𝑏2−4𝑎𝑐 2𝑎 R2= −𝑏± 𝑏 2 −4𝑎𝑐 2𝑎 2) R1= 𝑎2 + 𝑏2 e-0.2t cos 2t 3) E=mc2 Y=1 + 𝑛𝑥 1! + 𝑛 𝑛−1 𝑥2 2!
  • 13. MATLAB Code File 1. File name should not start with number 2. No Space in the file name 3. No library function name 4. No use of keywords reserved by MATALAB MATLAB Searching Mechanism 1. Workspace 2. Current directory 3. Set path directory
  • 14. Compare code in C with MATLAB 1. WAP program to perform addition of two numbers a and b with following constraint:  Do not use + operator i.e. c=a+b  Do not use –(-) operator i.e. c=a-(-b)  Do not use x(-1) i.e. c=a-b(-1)  Do not use c=b-(-a)  Do not c=b-(-a)  Do not use c=a- 𝟏 𝟏 −𝒃  Do not use c=b- 𝟏 𝟏 −𝒂  Do not use c= 𝒂 𝟐−𝒃 𝟐 𝒂−𝒃 Objectives: 1. Find the solution and logic 2. Compare C and Matlab code
  • 15. MATLAB Programming Exercise 1. WAP to find the roots of the quadratic equations 2. Ideal gas law problem to find volume 3. Let us see direct implementation using MATLAB………..
  • 18. %Matrix computations and operations >> %creating vectors and matrices >> %create a row vector, we can form a row vector. >> a=[1 3 6 8]; >> a a = 1 3 6 8 MATLAB Command With Syntax
  • 19. >> %create a column vector, >> b=[1;4;6;10]; >> b b = 1 4 6 10 MATLAB Command With Syntax
  • 20. >>Create the matrix x of 3 rows and 4 columns x=[12 23 21 3; 2 34 5 7; 31 32 33 34]; >> x x = 12 23 21 3 2 34 5 7 31 32 33 34 MATLAB Command With Syntax
  • 21. %elements of a Matrix >> z=x(2,3) z = 5 >> x1=x(1,:) x1 = 12 23 21 3 >> x2=x(:,2) x2 = 23 34 32 >> s=size(x) s = 3 4 MATLAB Command With Syntax
  • 22. Remove the n th X(n, : ) = [ ] x(2, : ) = [ ] Add a column of 4,s to the end of matrix. x( ; , 4) = 4 MATLAB Command With Syntax
  • 23. We can extend the colon notation to specify a sequence Create a vector v which starts at 1, with increment of 2 and stops at 10: v=1:2:10 v = 1 3 5 7 9 >> v=1:10 v = 1 2 3 4 5 6 7 8 9 10 MATLAB Command With Syntax
  • 24. x=[11 12 13 14; 21 22 23 24;31 32 33 34]; >> x x = 11 12 13 14 21 22 23 24 31 32 33 34 We can use this vector notation when referring to sub matrix: w=x(1:2:3, 2:4) MATLAB Command With Syntax
  • 25. w = 12 13 14 32 33 34 Rows :start at 1, increment by 2, stop at 3 Columns 2,3,4start at 2, stop at 4 default increment of 1 is used MATLAB Command With Syntax
  • 26. x=[11 12 13 14;21 22 23 24 ;31 32 33 34 ] x = 11 12 13 14 21 22 23 24 31 32 33 34 >> x4=x(1:2:3,2:4) x4 = 12 13 14 32 33 34 MATLAB Command With Syntax
  • 27. x4=x(1:2:2,2:4) x4 = 12 13 14 >> x4=x(1:1:3,2:4) x4 = 12 13 14 22 23 24 32 33 34 MATLAB Command With Syntax
  • 28. x4=x(1:1:2,2:4) x4 = 12 13 14 22 23 24 x4=[x;41 42 43 44] x4 = 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 x= [41 42 43 44;x] ? MATLAB Command With Syntax
  • 29. x4 = x(2:1:3,2:4) x4 = 22 23 24 32 33 34 x(4 , : ) = [41 42 43 44] x = 11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 MATLAB Command With Syntax
  • 30. x4=x(1:1:2,1:4) x4 = 11 12 13 14 21 22 23 24 >> x4=x(1:1:2,2:4) x4 = 12 13 14 22 23 24 >> x4=x(1:1:2,3:4) x4 = 13 14 23 24 MATLAB Command With Syntax
  • 31. Strings String handling Syntax S = 'Any Characters' S = [S1 S2 ...] S = strcat(S1, S2, ...) MATLAB Command With Syntax
  • 32. Examples Create a simple string that includes a single quote. msg = 'You''re right!' msg = You're right! Create the string name using two methods of concatenation. name = ['Thomas' ' R. ' 'Lee'] name = strcat('Thomas',' R.',' Lee') MATLAB Command With Syntax
  • 33. Create a vertical array of strings. C = strvcat('Hello','Yes','No','Goodbye‘) C = Hello Yes No Goodbye MATLAB Command With Syntax
  • 34. S = {'Hello' 'Yes' 'No' 'Goodbye'} S = 'Hello' 'Yes' 'No' 'Goodbye' Create a cell array of strings. S = {'Hello' 'Yes' 'No' 'Goodbye} MATLAB Command With Syntax
  • 35. 1. Commands for Managing a Session 2. MATLAB provides various commands for managing a session. 3. The following table provides all such commands − 4. I have forgotten the Variables! 5. The who command displays all the variable names you have used. 6. who 7. MATLAB will execute the above statement and return the following result MATLAB Command With Syntax
  • 36. >> who Your variables are: a b x >> whos Name Size Bytes Class Attributes a 1x4 32 double b 4x1 32 double x 3x4 96 double MATLAB Command With Syntax
  • 37. whos Name Size Bytes Class Attributes a 1x4 32 double b 4x1 32 double x 3x4 96 double MATLAB Command With Syntax
  • 38. Basic Task: Plot the function sin(x) between 0≤x≤4π  Create an x-array of 100 samples between 0 and 4π.  Calculate sin(.) of the x-array  Plot the y-array >>x=linspace(0,4*pi,100); >>y=sin(x); >>plot(y) 0 10 20 30 40 50 60 70 80 90 100 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 MATLAB Command With Syntax
  • 39. Plot the function e-x/3sin(x) between 0≤x≤4π  Create an x-array of 100 samples between 0 and 4π.  Calculate sin(.) of the x-array  Calculate e-x/3 of the x-array  Multiply the arrays y and y1 >>x=linspace(0,4*pi,100); >>y=sin(x); >>y1=exp(-x/3); >>y2=y.*y1; MATLAB Command With Syntax
  • 40. Plot the function e-x/3sin(x) between 0≤x≤4π  Multiply the arrays y and y1 correctly  Plot the y2-array >>y2=y.*y1; >>plot(y2) 0 10 20 30 40 50 60 70 80 90 100 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 MATLAB Command With Syntax
  • 41. Display Facilities  plot(.)  stem(.) Example: >>x=linspace(0,4*pi,100); >>y=sin(x); >>plot(y) >>plot(x,y) Example: >>stem(y) >>stem(x,y) 0 10 20 30 40 50 60 70 80 90 100 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0 10 20 30 40 50 60 70 80 90 100 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 MATLAB Command With Syntax
  • 42. Display Facilities  title(.)  xlabel(.)  ylabel(.) >>title(‘This is the sinus function’) >>xlabel(‘x (secs)’) >>ylabel(‘sin(x)’) 0 10 20 30 40 50 60 70 80 90 100 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 This is the sinus function x (secs) sin(x) MATLAB Command With Syntax
  • 43. Operators (relational, logical)  == Equal to  ~= Not equal to  < Strictly smaller  > Strictly greater  <= Smaller than or equal to  >= Greater than equal to  & And operator  | Or operator  ~ NOT MATLAB Command With Syntax
  • 44. Name Meaning ans Most recent answer. eps Accuracy of floating-point precision. i,j The imaginary unit √-1. Inf Infinity. NaN Undefined numerical result (not a number). pi The number π Special Variables and Constants MATLAB supports the following special variables and constants: MATLAB Command With Syntax
  • 45. Multiple Assignments You can have multiple assignments on the same line. For example, a = 2; b = 7; c = a * b MATLAB will execute the above statement and return the following result − c = 14 MATLAB Command With Syntax
  • 46. The clear command deletes all (or the specified) variable(s) from the memory. clear x % it will delete x, won't display anything clear % it will delete all variables in the % workspace % peacefully and unobtrusively MATLAB Command With Syntax
  • 47. Command Purpose clc Clears command window. clear Removes variables from memory. exist Checks for existence of file or variable. global Declares variables to be global. help Searches for a help topic. lookfor Searches help entries for a keyword. quit Stops MATLAB. who Lists current variables. whos Lists current variables (long display). Commands for Managing a Session MATLAB provides various commands for managing a session. The following table provides all such commands − MATLAB Command With Syntax
  • 48. MATLAB provides various useful commands for working with the system, like saving the current work in the workspace as a file and loading the file later. It also provides various commands for other system- related activities like, displaying date, listing files in the directory, displaying current directory, etc. MATLAB Command With Syntax
  • 49. Command Purpose cd Changes current directory. date Displays current date. delete Deletes a file. diary Switches on/off diary file recording Commands for Working with the System The following table displays some commonly used system-related commands − MATLAB Command With Syntax
  • 50. Command Purpose disp Displays contents of an array or string. fscanf Read formatted data from a file. format Controls screen-display format. fprintf Performs formatted writes to screen or file. input Displays prompts and waits for input. ; Suppresses screen printing. Input and Output Commands MATLAB provides the following Input and output related commands − MATLAB Command With Syntax
  • 51. Assignments 1. Create a matrix A of zeros [2x4], and B of ones[2x3]. i. Add A by 2 to create matrix of twos. ii. Can we add A+B? and A-B? justify your Answer. 2. Create matrix of 4 rows and 3 columns. i. Add X by 4 to create new matrix called Y. ii. Form C= X+Y iii. Form D= X-Y iv. Remove second row. v. Add a column of 4’s to the end of matrix. 3. Using matrix operations to solve the following system of linear equations. 4x - 2y + 6z = 8 2x + 8y + 2z = 4 6x +10y +3z = 0. MATLAB Command With Syntax