Vectors, Functions, and Plots in Matlab
Entering vectors:
In Mat lab the basic objects are matrices that is arrays of numbers. Vectors are able to be thought of as special matrices. A row vector is recorded as a 1 × n matrix also a column vector is recorded as am × 1 matrix. To enter a row vector in Mat lab enter the following at the prompt ( > ) in the command window:
> v = [0 1 2 3]
And press enter. Mat lab will print out the row vector. To enter a column vector type
> u = [9; 10; 11; 12; 13]
You are able to access an entry in a vector with
>u(2)
And change the value of that entry with
>u(2) = 47
You are capable to extract a slice out of a vector with
>u(2:4)
You are able to change a row vector into a column vector and vice versa easily in Mat lab using:
> w = v’
(This is called transposing the vector as well as we call’ the transpose operator.) There are as well useful shortcuts to make vectors such as
> x = -1:.1:1
and
> y = linspace(0,1,11)
Plotting Data:
Consider the following table acquired from experiments on the viscosity of a liquid. We are able to enter:
This data into Mat lab with the following commands entered in the command window:
> x = [ 5 20 30 50 55 ]> y = [ 0.08 0.015 0.009 0.006 0.0055]
Inserting the name of the variable retrieves its current values. For illustration:>x>y
We are able to plot data in the form of vectors using the plot command:
>plot(x,y)
This will make a graph with the data points connected by lines. If you would choose that thedata points be represented by symbols you can do so. For illustration:
>plot(x,y,’*’)>plot(x,y,’o’)>plot(x,y,’.’)
Data as a Representation of a Function:
A main theme in this course is that often we are interested in a certain function y = f(x) howeverthe only information we have about this function is a discrete set of data {(xi, yi)}. Plotting thedata as we did above is able to be thought of envisioning the function using just the data. We will discoverlater that we can also do other things with the function like differentiating and integrating, merelyusing the available data. A numerical method, the topic of this course means doing mathematics bycomputer. Since a computer can merely store a finite amount of information we will approximately alwaysbe working with a finite discrete set of values of the function (data) rather than a formula for thefunction.
Built-in Functions:
If we wish to deal with formulas for functions Mat lab contains a number of built-in functions,including all the typical functions, such as sin( ), exp( ), and so on. The meaning of the majority of these isclear. The dependent variable (input) forever goes in parentheses in Mat lab. For example
>sin(pi)
Must return the value of sin π, which is of course 0 and
>exp(0)
Will return e0 which is 1 More significantly the built-in functions can operate not only on singlenumbers however on vectors. For illustration:
> x = linspace(0,2*pi,40)> y = sin(x)>plot(x,y)
Will return a plan of sin x on the interval [0, 2π]
A few of the built-in functions in Mat lab include:
cos( ), tan( ), sinh( ), cosh( ), log( )(natural logarithm), log10() (log base 10), asin( ) (inverse sine), acos( ), atan( ). To findout more about a function utilize the help command; try
> help plot
User-Defined Inline Functions:
If we wish to deal with a function that is a combination of the built-in functions, Mat lab has acouple of ways for the user to define functions. One that we will use lots is the inline function whichis a way to define a function in the command window. The following is a usual inline function:
> f = inline(’2*x.^2 - 3*x + 1’,’x’)
This produces the function f(x) = 2x2 − 3x + 1. To acquire a single value of this function enter:
>f(2.23572)
Merely as for built-in functions, the function f as we defined it is able to operate not only on single numbersbut on vectors. Attempt the following:
> x = -2:.2:2> y = f(x)
This is an example of vectorizationthat is putting several numbers into a vector as well as treating thevector all at once, rather than one component at a time and is one of the strengths of Mat lab.
The reason f(x) works when x is a vector is for the reason that we represented x2 by x.^2. The turns the exponent operator ^ into entry-wise exponentiation, therefore that [-2 -1.8 -1.6].^2 denotes[(−2)2, (−1.8)2, (−1.6)2] and yields [4 3.24 2.56]. On the contrary [-2 -1.8 -1.6]^2 denotes the matrixproduct [−2,−1.8,−1.6][−2,−1.8,−1.6] as well as yields only an error. The is needed in .^, .*,and ./. It isn’t needed when you * or / by a scalar or for +.
The results are able to be plotted using the plot command just as for data:
Notice that previous to plotting the function we in effect converted it into data. Plotting on any machinefor all time requires this step.
Latest technology based Matlab Programming Online Tutoring Assistance
Tutors, at the www.tutorsglobe.com, take pledge to provide full satisfaction and assurance in Matlab Programming help via online tutoring. Students are getting 100% satisfaction by online tutors across the globe. Here you can get homework help for Matlab Programming, project ideas and tutorials. We provide email based Matlab Programming help. You can join us to ask queries 24x7 with live, experienced and qualified online tutors specialized in Matlab Programming. Through Online Tutoring, you would be able to complete your homework or assignments at your home. Tutors at the TutorsGlobe are committed to provide the best quality online tutoring assistance for Matlab Programming Homework help and assignment help services. They use their experience, as they have solved thousands of the Matlab Programming assignments, which may help you to solve your complex issues of Matlab Programming. TutorsGlobe assure for the best quality compliance to your homework. Compromise with quality is not in our dictionary. If we feel that we are not able to provide the homework help as per the deadline or given instruction by the student, we refund the money of the student without any delay.
Research Management Essay Writing Assignment Help service is a better choice for secuting top grades at inexpensive price range.
tutorsglobe.com staphylococcal infections assignment help-homework help by online staphylococcus aureus tutors
Cytoplasmic male sterility tutorial all along with the key concepts of Cytoplasmic-genetic male sterility, Cytoplasmic male sterility in hybrid breeding, Cytoplasmic male sterility in the hybrid maize breeding
Theory and lecture notes of Change in Income and Optimal Choice all along with the key concepts of change in income and optimal choice, Change in Price and Optimal Choice. Tutorsglobe offers homework help, assignment help and tutor’s assistance on change in income and optimal choice.
tutorsglobe.com hyperparathyroidism assignment help-homework help by online parathyroid gland tutors
The wish to communicate directly through voice, on a higher rate of speed than possible by general telegraphy, led to additional research. That research led to the progress of MODULATION.
theory and lecture notes of dc motors ii all along with the key concepts of torque, speed, force, power delivered to load, output power and efficiency, speed-torque characteristics. tutorsglobe offers homework help, assignment help and tutor’s assistance on theory of dc motors ii.
Theory and lecture notes of Exploring Data: Nonlinear Models all along with the key concepts of TI-82/TI-83 Models, TI-85 Models, Least Squares Regression Model, TI-82/TI-83, Correlation Coefficient. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Exploring Data: Nonlinear Models.
tutorsglobe.com distinguishing features of fungi assignment help-homework help by online fungi tutors
www.tutorsglobe.com offers requirement analysis homework help, assignment help, case study, writing homework help, Software Engineering online tutoring assistance by computer science tutors.
Polymer Solutions tutorial all along with the key concepts of Thermodynamics of Polymer Solution, Phase Equilibrium, Polymer solubility
Introduction to Organic Chemistry III tutorial all along with the key concepts of Properties of Organic Compounds, History of Organic Chemistry, Difference between Organic and an Inorganic Compound, Classification of Organic Compounds, IUPAC Nomenclature of Organic Compounds
Optical instruments tutorial all along with the key concepts of Microscope, Simple Microscope (in normal use), Simple Microscope with Image at Infinity, Compound Microscope, Astronomical Telescope in Normal Adjustment
tutorsglobe.com management of hazardous wastes assignment help-homework help by online waste management tutors
modern periodic law tutorial all along with the key concepts of long form of the periodic table, nomenclature of elements
1932739
Questions Asked
3689
Tutors
1489414
Questions Answered
Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!