SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Matlab 7

Lec 2-Fundamentals
Topics

variables, operators and expressions;

arrays (including vectors and matrices);

basic input and output;

repetition (for);

decision (if);
Variables
must start with a letter
can be alphabets (a-z), digits 0-9,underscore(_)
may be as long as you like
Matlab rem only first 31 characters
Eg r2d2 dhoni walle nano etc
Pay – day ,2s , name$ galtiyaaaaaaaannnn????????

Official Matlab Documentation refers variables as Arrays
scalar or vector

error message:
??? Undefined function or variable ...
Matlab is Case Sensitive
camel Caps method eg. camelCaps

Command and Function names are case sensitive
Workspace
variables you create during a session remain in workspace
untill you clear them using clear

whos – size of variables who diff dekho
ans – function=lastvalue of exp evaluated but not
      assigned to a variable
     example socho!

double = holds a numeric value = double precision
         floating point
clear vname1 vname2
Workspace Browser
the myconstant.m example

g=9.8;
avo=6.23e23

run myconstant at start of session,Workspace is loaded
Arrays : Vectors and Matrices
Basic Idea Of a Matrix – Rows and Columns




Vector – Special Type of Matrix,1 Row,1 Column;
         called list or arrays in some other Prog Lang




Matlab Handles Vectors and Matrices in a Same Manner
Vectors

Enter a statement in command line :
x = [1 3 0 -1 5]

Now enter disp(x) to see vector kaise dikhta hai
Also try y = [2,3,5]
Then whos command or size(y) command

Iska o/p kya hoga ? : - x =[130-15] bataaaaaoooooo?????

a = [ 1 2 3]
b = [4 5]
c = [ a –b]
Iska o/p bataaaaaooo ab????????
Iske bare me kya khyal hai?? :
a = [1 3 7];
a = [a 0 -1];

Vector can also be initialized as

x = 1:10;
x = 1:0.5:4;
x=1:2:6 try karo! Kya galti hai statement me????
x=0:-2:-5

This is list method of initializing!make sure
1.Elements in list must be enclosed in square bracket
2.Shud be separated by either space or commas
Ek aur tarika hai ki ap linspace function use karo!

Yeh try karo
linspace(0,pi/2,10)

Ye 10 equally space points ka vector create karta hai
0 and pi include karke
Transposing vectors sanjhte hai ab:::




Abhi tak Row vectors me khel rahe the abhi column vectors me
ate hai!

U need to transpose the row vectors to get column vectors

Try this
y=[ 1 4 8 0 -1]’

Sign used is the aposthrophe
Ab ati hai vectors ki subscripts:
Try this
Row vector of 7 random nos
r = rand(1,7)
Ab try karo
r(3)
Isme joh no. 3 dale hai who subscript hai!

Iske jawab do sochke and karke
r(2:4)
r(1:2:7)
r([1 7 2 6])
Conclusion abt subscripts:

Subscript is indicated inside () brackets

It may be a scalar or vector

Subscript always starts at 1

Fractional subscripts r always rounded down
x(1.9) will be x(1)
Matrices

Matrix = rows and columns
Try this
a = [ 1 2 3;4 5 6 ]

Ab apna transpose ka knowledge jhalkao!!!!

Try a’
Hum matrix same length ke vectors se bhi bana sakte hai!
x=0:30:180;
table = [ x' sin(x*pi/180)']
Capturing o/p
Either copy paste
Ya try this

diary kp2
diary off
DANCE TIME SURPRISE
Problem statement:
The equation for vertical motion under gravity is given by
S = ut – ½ gt^2

We ve to compute the value of s over a period of abt 12.3 sec
At intervals of 0.1 sec

Initial velocity 60 m/sec lijiye g = 9.8

M-file banaiye

Sabse pahile 4 points ka structure plan sochiye and paper pe
  likhiye!next silde se match karke dekhiye ki kya ap sahi hai
  ya ap kitte sahi hai????
Structure Plan

1. Assign the data (g, u and t) to MATLAB variables.

2. Calculate the value of s according to the formula.

3. Plot the graph of s against t.



4. Stop.
t wala statement vector initialize karta hai

. Operator ko dekho ye vectors ke liye hai!bad hum discuss
   karenge!

Formula for s is evaluated for every element of vector t
  making another vector

Disp command ka use table display ke liye

,,,, and … ka use
OVERRRRRRRRR aj ke liye

Weitere ähnliche Inhalte

Was ist angesagt?

L2 graphs piecewise, absolute,and greatest integer
L2 graphs  piecewise, absolute,and greatest integerL2 graphs  piecewise, absolute,and greatest integer
L2 graphs piecewise, absolute,and greatest integerJames Tagara
 
Piecewise function lesson 3
Piecewise function lesson 3Piecewise function lesson 3
Piecewise function lesson 3aksetter
 
Passing an Array to a Function (ICT Programming)
Passing an Array to a Function (ICT Programming)Passing an Array to a Function (ICT Programming)
Passing an Array to a Function (ICT Programming)Fatima Kate Tanay
 
8 elementary sorts-selection
8 elementary sorts-selection8 elementary sorts-selection
8 elementary sorts-selectionirdginfo
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...Dharmendra Prasad
 
9.3 Solving Systems With Gaussian Elimination
9.3 Solving Systems With Gaussian Elimination9.3 Solving Systems With Gaussian Elimination
9.3 Solving Systems With Gaussian Eliminationsmiller5
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsDrishti Bhalla
 
Piecewise functions updated_2016
Piecewise functions updated_2016Piecewise functions updated_2016
Piecewise functions updated_2016Benjamin Madrigal
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
9.2 Matrices
9.2 Matrices9.2 Matrices
9.2 Matricessmiller5
 

Was ist angesagt? (20)

Domain and range
Domain and rangeDomain and range
Domain and range
 
L2 graphs piecewise, absolute,and greatest integer
L2 graphs  piecewise, absolute,and greatest integerL2 graphs  piecewise, absolute,and greatest integer
L2 graphs piecewise, absolute,and greatest integer
 
Piecewise function lesson 3
Piecewise function lesson 3Piecewise function lesson 3
Piecewise function lesson 3
 
Array and string
Array and stringArray and string
Array and string
 
Gr10 piecewise functions
Gr10 piecewise functionsGr10 piecewise functions
Gr10 piecewise functions
 
Lec5
Lec5Lec5
Lec5
 
Passing an Array to a Function (ICT Programming)
Passing an Array to a Function (ICT Programming)Passing an Array to a Function (ICT Programming)
Passing an Array to a Function (ICT Programming)
 
8 elementary sorts-selection
8 elementary sorts-selection8 elementary sorts-selection
8 elementary sorts-selection
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
 
Session 7 En
Session 7 EnSession 7 En
Session 7 En
 
9.3 Solving Systems With Gaussian Elimination
9.3 Solving Systems With Gaussian Elimination9.3 Solving Systems With Gaussian Elimination
9.3 Solving Systems With Gaussian Elimination
 
Recursion
RecursionRecursion
Recursion
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
C programming slide c05
C programming slide c05C programming slide c05
C programming slide c05
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Sorting ppt
Sorting pptSorting ppt
Sorting ppt
 
Piecewise functions updated_2016
Piecewise functions updated_2016Piecewise functions updated_2016
Piecewise functions updated_2016
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
9.2 Matrices
9.2 Matrices9.2 Matrices
9.2 Matrices
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 

Andere mochten auch (20)

Michaelpritchard
MichaelpritchardMichaelpritchard
Michaelpritchard
 
VPN
VPNVPN
VPN
 
Matlab
MatlabMatlab
Matlab
 
Matlab
MatlabMatlab
Matlab
 
Tech tut
Tech tutTech tut
Tech tut
 
Michaelpritchard
MichaelpritchardMichaelpritchard
Michaelpritchard
 
Lec1
Lec1Lec1
Lec1
 
Logical vectors
Logical vectorsLogical vectors
Logical vectors
 
Fb Nnew Pps
Fb Nnew PpsFb Nnew Pps
Fb Nnew Pps
 
Improving your driveway, path or patio.
Improving  your driveway, path or patio.Improving  your driveway, path or patio.
Improving your driveway, path or patio.
 
Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
 
SIB Green IT Policy
SIB Green IT PolicySIB Green IT Policy
SIB Green IT Policy
 
Introduction into GIT
Introduction into GITIntroduction into GIT
Introduction into GIT
 
BarCamp in Saigon
BarCamp in SaigonBarCamp in Saigon
BarCamp in Saigon
 
An approach to implement model classes in zend
An approach to implement model classes in zendAn approach to implement model classes in zend
An approach to implement model classes in zend
 
Los espacios en la BECREA. junta de andalucía.
Los espacios en la BECREA. junta de andalucía.Los espacios en la BECREA. junta de andalucía.
Los espacios en la BECREA. junta de andalucía.
 
Servicios tradicionales en la BECREA
Servicios tradicionales en la BECREAServicios tradicionales en la BECREA
Servicios tradicionales en la BECREA
 
How to apply Agile in Marketing
How to apply Agile in MarketingHow to apply Agile in Marketing
How to apply Agile in Marketing
 
GUÍA DE BIBLIOTECAS ESCOLARES. 6. Extensión cultural. Director: José García G...
GUÍA DE BIBLIOTECAS ESCOLARES. 6. Extensión cultural. Director: José García G...GUÍA DE BIBLIOTECAS ESCOLARES. 6. Extensión cultural. Director: José García G...
GUÍA DE BIBLIOTECAS ESCOLARES. 6. Extensión cultural. Director: José García G...
 
Client Satisfaction as engine of the continuous improvement
Client Satisfaction as engine of the continuous improvementClient Satisfaction as engine of the continuous improvement
Client Satisfaction as engine of the continuous improvement
 

Ähnlich wie Lec2

Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMohd Esa
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
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
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.pptkebeAman
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlabTUOS-Sam
 
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 ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 introRagu Nathan
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondMahuaPal6
 

Ähnlich wie Lec2 (20)

presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
Matlab ppt
Matlab pptMatlab ppt
Matlab ppt
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
Matlab-free course by Mohd Esa
Matlab-free course by Mohd EsaMatlab-free course by Mohd Esa
Matlab-free course by Mohd Esa
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
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
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
bobok
bobokbobok
bobok
 
Lecture two
Lecture twoLecture two
Lecture two
 
Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
Matlab1
Matlab1Matlab1
Matlab1
 
Matlab ch1 intro
Matlab ch1 introMatlab ch1 intro
Matlab ch1 intro
 
From zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyondFrom zero to MATLAB hero: Mastering the basics and beyond
From zero to MATLAB hero: Mastering the basics and beyond
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 

Kürzlich hochgeladen

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 

Kürzlich hochgeladen (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Lec2

  • 2. Topics variables, operators and expressions; arrays (including vectors and matrices); basic input and output; repetition (for); decision (if);
  • 3. Variables must start with a letter can be alphabets (a-z), digits 0-9,underscore(_) may be as long as you like Matlab rem only first 31 characters Eg r2d2 dhoni walle nano etc Pay – day ,2s , name$ galtiyaaaaaaaannnn???????? Official Matlab Documentation refers variables as Arrays scalar or vector error message: ??? Undefined function or variable ...
  • 4. Matlab is Case Sensitive camel Caps method eg. camelCaps Command and Function names are case sensitive
  • 5. Workspace variables you create during a session remain in workspace untill you clear them using clear whos – size of variables who diff dekho ans – function=lastvalue of exp evaluated but not assigned to a variable example socho! double = holds a numeric value = double precision floating point clear vname1 vname2 Workspace Browser
  • 6. the myconstant.m example g=9.8; avo=6.23e23 run myconstant at start of session,Workspace is loaded
  • 7. Arrays : Vectors and Matrices Basic Idea Of a Matrix – Rows and Columns Vector – Special Type of Matrix,1 Row,1 Column; called list or arrays in some other Prog Lang Matlab Handles Vectors and Matrices in a Same Manner
  • 8. Vectors Enter a statement in command line : x = [1 3 0 -1 5] Now enter disp(x) to see vector kaise dikhta hai Also try y = [2,3,5] Then whos command or size(y) command Iska o/p kya hoga ? : - x =[130-15] bataaaaaoooooo????? a = [ 1 2 3] b = [4 5] c = [ a –b] Iska o/p bataaaaaooo ab????????
  • 9. Iske bare me kya khyal hai?? : a = [1 3 7]; a = [a 0 -1]; Vector can also be initialized as x = 1:10; x = 1:0.5:4; x=1:2:6 try karo! Kya galti hai statement me???? x=0:-2:-5 This is list method of initializing!make sure 1.Elements in list must be enclosed in square bracket 2.Shud be separated by either space or commas
  • 10. Ek aur tarika hai ki ap linspace function use karo! Yeh try karo linspace(0,pi/2,10) Ye 10 equally space points ka vector create karta hai 0 and pi include karke
  • 11. Transposing vectors sanjhte hai ab::: Abhi tak Row vectors me khel rahe the abhi column vectors me ate hai! U need to transpose the row vectors to get column vectors Try this y=[ 1 4 8 0 -1]’ Sign used is the aposthrophe
  • 12. Ab ati hai vectors ki subscripts: Try this Row vector of 7 random nos r = rand(1,7) Ab try karo r(3) Isme joh no. 3 dale hai who subscript hai! Iske jawab do sochke and karke r(2:4) r(1:2:7) r([1 7 2 6])
  • 13. Conclusion abt subscripts: Subscript is indicated inside () brackets It may be a scalar or vector Subscript always starts at 1 Fractional subscripts r always rounded down x(1.9) will be x(1)
  • 14. Matrices Matrix = rows and columns Try this a = [ 1 2 3;4 5 6 ] Ab apna transpose ka knowledge jhalkao!!!! Try a’ Hum matrix same length ke vectors se bhi bana sakte hai! x=0:30:180; table = [ x' sin(x*pi/180)']
  • 15. Capturing o/p Either copy paste Ya try this diary kp2 diary off
  • 16.
  • 18. Problem statement: The equation for vertical motion under gravity is given by S = ut – ½ gt^2 We ve to compute the value of s over a period of abt 12.3 sec At intervals of 0.1 sec Initial velocity 60 m/sec lijiye g = 9.8 M-file banaiye Sabse pahile 4 points ka structure plan sochiye and paper pe likhiye!next silde se match karke dekhiye ki kya ap sahi hai ya ap kitte sahi hai????
  • 19. Structure Plan 1. Assign the data (g, u and t) to MATLAB variables. 2. Calculate the value of s according to the formula. 3. Plot the graph of s against t. 4. Stop.
  • 20. t wala statement vector initialize karta hai . Operator ko dekho ye vectors ke liye hai!bad hum discuss karenge! Formula for s is evaluated for every element of vector t making another vector Disp command ka use table display ke liye ,,,, and … ka use