![]() ![]() Color or shape variations are listed at the end of a plot function within quotations. Being able to differentiate the physical appearance of graphs will be especially important when plotting several data sets in the same plan, which will be addressed shortly. MATLAB plots enable the user to modify the physical appearance of the code to incorporate colors and shapes which will help depict data more effectively than a simple line. An example of the scatter function is included in example 1 below. Additional replacements that can be used in place of the plot function include the bar function for bar graphs, the stairstep function for stairstep graphs, and the stem plot for stem graphs. This type of function is when the vector used to create the x-axis is important, as the number of points in the vector will dictate the number of points in the scatter plot. To create a function that plots a scatter graph instead of a linear graph, use the function scatter in the place of the plot, which will only place points. There are many methods available within MATLAB that can assist in producing graphs including scatter plots, line plots, or other non-linear display methods. An example is included below which also uses the linspace function to generate vectors for the x-axis of the plot. This will result in several lines being graphed on the same plot, which can be valuable when comparing data or wanting to save space when displaying information. When writing code, use the hold-on command in between commands plotting each line. ![]() The following image contains concepts addressed above within an actual MATLAB code to create graphs like the one represented in the above examples of commands.Īnother easy method to plot several lines on the same graph is easy within MATLAB. > 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. 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. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |