Presentation is loading. Please wait.

Presentation is loading. Please wait.

The ‘PLOT’ Command (1) >> X = linspace(0, 2*pi, 30); >> Y = sin(X); >> plot(X,Y) >> Z = cos(X); >> plot(X,Y,X,Z);

Similar presentations


Presentation on theme: "The ‘PLOT’ Command (1) >> X = linspace(0, 2*pi, 30); >> Y = sin(X); >> plot(X,Y) >> Z = cos(X); >> plot(X,Y,X,Z);"— Presentation transcript:

1

2 The ‘PLOT’ Command (1) >> X = linspace(0, 2*pi, 30); >> Y = sin(X); >> plot(X,Y) >> Z = cos(X); >> plot(X,Y,X,Z);

3 The ‘PLOT’ Command (2) >> W = [Y ; Z] >> plot (X,W) Rotate by 90 degrees >> plot(W,X)

4 PLOT Options >> plot(X,Y,’g:’) >> plot(X,Y,’r-’) >> plot(X,Y,’ko’) >> plot(X,Y,’g:’,X,Z,’r-’,X,Y,’wo’,X,Z,’c+’);

5 PLOT Options >> grid on >> grid off >> xlabel(‘this is the x axis’); >> ylabel(‘this is the y axis’); >> title(‘Title of Graph’); >> text(2.5, 0.7, ’sin(x)’); >> legend(‘sin(x)’, ‘cos(x)’)

6 SUBPLOT Command Subplot(m,n,p) –creates a m-by-n matrix in and plots in the pth plane. subplot(2,2,1) plot(X,Y) subplot(2,2,2) plot(X,Z) subplot(2,2,3) plot( X,Y,X,Z) subplot(2,2,4) plot(W,X)

7 Specialised matrices compan gallery hadamard hankel pascal rosser vander wilkinson Companion matrix Higham test matrices Hadamard matrix Hankel matrix Pascal matrix. Classic symmetric eigenvalue test problem Vandermonde matrix Wilkinson's eigenvalue test matrix

8 Polynomials Polynomials are represented as row vectors with its coefficients in descending order, e.g. X 4 - 12X 3 + 0X 2 +25X + 116 p = [1 -12 0 25 116]

9 Polynomials The roots of a polynomial are found as follows r = roots(p) roots are represented as a column vector

10 Polynomials Generating a polynomial from its roots polyans = poly(r) includes imaginary bits due to rounding mypolyans = real(polyans)

11 Polynomial Addition/Sub a = [1 2 3 4] b = [1 4 9 16] c = a + b d = b - a

12 Polynomial Addition/Sub What if two polynomials of different order ? X 3 + 2X 2 +3X + 4 X 6 + 6X 5 + 20X 4 - 52X 3 + 81X 2 +96X + 84 a = [1 2 3 4] e = [1 6 20 52 81 96 84] f = e + [0 0 0 a] or f = e + [zeros(1,3) a]

13 Polynomial Multiplication a = [1 2 3 4] b = [1 4 9 16] Perform the convolution of two arrays ! g = conv(a,b) g = 1 6 20 50 75 84 64

14 Polynomial Division a = [1 2 3 4] g = [1 6 20 50 75 84 64] Perform the deconvolution of two arrays ! [q,r] = deconv(g, a) q ={quotient} 1 4 9 16 r ={remainder} 0 0 0 0

15 Polynomial Differentiation f = [1 6 20 48 69 72 44] h = polyder(f) h = 6 30 80 144 138 72

16 Polynomial Evaluation x = linspace(-1,3) p = [1 4 -7 -10] v = polyval(p,x) plot (x,v), title(‘Graph of P’)

17 Rational Polynomials Rational polynomials, seen in Fourier, Laplace and Z transforms We represent them by their numerator and denominator polynomials we can use residue to perform a partial fraction expansion We can use polyder with two inputs to differentiate rational polynomials


Download ppt "The ‘PLOT’ Command (1) >> X = linspace(0, 2*pi, 30); >> Y = sin(X); >> plot(X,Y) >> Z = cos(X); >> plot(X,Y,X,Z);"

Similar presentations


Ads by Google