Numerical Methods using MATLAB
Format: PDF / Kindle (mobi) / ePub
Numerical Methods with MATLAB provides a highly-practical reference work to assist anyone working with numerical methods. A wide range of techniques are introduced, their merits discussed and fully working MATLAB code samples supplied to demonstrate how they can be coded and applied.
Numerical methods have wide applicability across many scientific, mathematical, and engineering disciplines and are most often employed in situations where working out an exact answer to the problem by another method is impractical.
Numerical Methods with MATLAB presents each topic in a concise and readable format to help you learn fast and effectively. It is not intended to be a reference work to the conceptual theory that underpins the numerical methods themselves. A wide range of reference works are readily available to supply this information. If, however, you want assistance in applying numerical methods then this is the book for you.
x=rand(10,1); y=rand(10,1)+.1*rand(10,1); scatter(x,y); Similarly, to create a bar graph of the following height data in a class of 50,Height 5’-5’4’’ 5’4’’-5’8’’ 5’8’’-6’ 6’-6’4’’ 6’4’’-6-8’’ No of Students 5 15 15 11 4 we can execute the following code: nofS=[5 15 15 11 4]; h=bar(1:5,nofS); Quiver Plots Quiver plots are used to show the flow at different grid points. It requires four matrices X, Y, U and V and at each grid point (X ij , Y ij ), it puts an arrow pointing
to denote whether the optimization was successful or terminated due to some problem. Positive exit flags correspond to successful outcomes. Negative exit flags correspond to unsuccessful outcomes where the solver has failed to compute an optimal solution. The zero exit flag corresponds to the solver being halted by exceeding an iteration limit or limit on the number of functions. The exact ids and interpretations for a specific function can be seen by typing help followed by the function name.
student.name='John'; student.class=10; student.cgpa=3.5; which results in a structure matrix of size 1×1. To create a second element of the above matrix, we can write student(2).name='Joe'; student(2).class=9; student(2).cgpa=3.7; Saving/Loading Variables Since MATLAB deletes all its variables when it is closed, you can save all the variables in a data file for the next session by executing the following save filename Similarly we can load all the variables using load filename
for data representation) such as sum. The following example computes the average velocity of a system from a vector V containing the instantaneous velocities of it at uniform time samples: avgV=sum(V)/length(V) Note that since sum(V) and length(V) are both scalars, using the ./ and / operators result in the same answer, therefore we can use / here. Other similar operations are prod, mean, etc. Note that for higher dimensional matrices, these operations can be done in any dimension which
element located at the second row and third column of the matrix A: y=A(2,3); Similarly, to change the (3,4)th element of A to 5 we can write A(3,4)=5 We can extract multiple columns and rows by specifying the indices as vectors. The following will extract a square matrix containing the second and third rows and third and first columns of the matrix A y=A([2 3],[3 1]); The following will extract all rows and the 5th and 4th columns of the matrix A y=A(:,[5 4]) where : denotes all. The