12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.3 Plotting MatricesIf one <strong>of</strong> the arguments to the plot comm<strong>and</strong> is a matrix, matlab willuse the columns <strong>of</strong> the matrix to plot a set <strong>of</strong> lines, one line per column:>> q = [1 1 1;2 3 4;3 5 7;4 7 10]q =1 1 12 3 43 5 74 7 10>> plot(q)>> gridmatlab plots the columns <strong>of</strong> the matrix q against the row index. Youcan also supply an x variable:>> x = [0 1 3 6]x =0 1 3 6>> plot(x,q)>> gridHere the x values are not uniformly spaced, but they are the same foreach column <strong>of</strong> q. You can also plot a matrix <strong>of</strong> x values against a vector<strong>of</strong> y values (be careful: the y values are in the vector x):plot(q,x)gridIf both the x <strong>and</strong> y arguments are matrices, matlab will plot the successivecolumns on the same plot:c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!