Graphs with MATLAB (Taken from "MATLAB for Beginners: A Gentle Approach") by Peter Kattan - Read Online
Graphs with MATLAB (Taken from "MATLAB for Beginners
0% de Graphs with MATLAB (Taken from "MATLAB for Beginners completado

Acerca de



This concise article of thirty pages takes you on a short tour on how to plot graphs using MATLAB. The presentation covers both two-dimensional and three-dimensional graphs. It is shown first how to plot a simple two-dimensional curve between two x and y vectors. This is followed by different commands to control the appearance of this curve – using color, curve type, legend, title, etc. Then it is shown how to plot two curves on the same graphs, followed by plotting four graphs on the same paper. Finally, different types of three-dimensional graphs are plotted including surface, mesh, and contour lines. The presentation is made in the form of solved examples showing the exact MATLAB commands used and the output. At the end of the article, there are about eleven unsolved exercises for students to practice. The solutions to all the exercises are also provided. This article is taken form the bestselling book “MATLAB for Beginners: A Gentle Approach.”

Publicado: Peter Kattan el
ISBN: 9781301727612
Enumerar precios: $4.95
Disponibilidad de Graphs with MATLAB (Taken from "MATLAB for Beginners: A G...
Con una prueba gratuita de 30 días usted puede leer en línea gratis
  1. Este libro se puede leer en hasta 6 dispositivos móviles.


Vista previa del libro

Graphs with MATLAB (Taken from "MATLAB for Beginners - Peter Kattan

Ha llegado al final de esta vista previa. ¡Regístrese para leer más!
Página 1 de 1


Graphs in MATLAB

In this article we explain how to plot graphs in MATLAB. Both two-dimensional and three-dimensional graphs are presented. A graph in MATLAB appears in its own window (not on the command line). First, we will consider two-dimensional or planar graphs. To plot a two-dimensional graph, we need two vectors. Here is a simple example using two vectors x and y along with the MATLAB command plot:

>> x = [1 2 3 4 5]

x =

1     2     3     4     5

>> y = [3 9 12 10 6]

y =

3     9    12    10     6

>> plot(x,y)

The resulting graph is displayed in its own window and is shown in Figure 1. Note how the command plot was used above along with the two vectors x and y. This is the simplest use of this command in MATLAB.

We can add some information to the above graph using other MATLAB commands that are associated with the plot command. For example, we can use the title command to add a title to the graph. Also, we can use the MATLAB commands xlabel and ylabel to add labels to the x-axis and the y-axis. But before using these three commands (title, xlabel, ylabel), we need to keep the plotted graph in its window.