> legend(‘Name of First Plot’,’Name of Second Plot’) Note that the font size can be modified by adding ‘FontSize’ followed by the desired font size after the title in the command. The following example is a general example of how to label the graph. Listing each of these commands after a plot command will add the labels to the graph. In order to place labels and titles in MATLAB plots, the following commands can be used to generate labels. This notation is one way the user can plot as many sets of variables as needed, though it is limited to 2D. For example, for the following variables, x, y, and x, the user would graph an x vs y plot and a x vs z plot in the same axis by using the following notation. This can be done by listing each set of variables in a series. Several functions can be graphed within a single MATLAB, enabling the user to display several data sets more efficiently. The linspace command is used below in the example plotting two functions on the same graph. An example is shown below, which represents a vector containing 100 values ranging between 0 and 10. ![]() The linspace command selects the initial value, the final value, and how many values should be generated in between this range. As a result, equations such as the y-value in the above example are much more prevalent than predetermined vector operations.Īnother way to generate an evenly spaced vector to use when plotting a function is the linspace command. Most applications of the plot function within MATLAB will incorporate an equation for one of the variables, thus creating the need for a plot to visualize the data. For example, if you have a set range of values (let’s say x = 1,2,3,4,5 for this example) and another variable that is a multi ple of x (say y = 3*x for this example) the following code could be used to plot the above example. The above technique can be modified to make one variable dependent on the other. ![]() This is an easy way to generate a linear graph but most applications within scripts will be more involved than this. This notation will generate a graph with a line running from the point (5,11 ) to (10,16). The following example shows how the user could assign the range for the x- and y-axis, respectively, using vectors. A simple way to graph the first-order line onto a plane is by listing the range of values for both the x and y coordinate which need to be graphed. The plot function operates by plotting data assigned to a variable onto a graph. General graphs can be created by the user with the plot command, which can be modified to incorporate colors, symbols, labels, and other aspects of the graph to ensure that the data is able to be read and interpreted by the user. MATLAB has tools that enable the user to display data within visual forms such as tables, 2D, or 3D graphs to increase readability for the user. Chapter 6: Graphing in MATLAB Creating Graphs
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |