This can also be achieved by calling the plot function in a loop where the plotting function can be defined as function of the looping variable. Matlab enables user to plot more than two number of lines in single plane. The code is written to display the data mapping each line to its corresponding plotting function. Including legend to distinguish the line plots: Application of the attribute ‘legend’ adds information to the plot to guide the user in identifying the lines with respect to their plotting functions. %Placing the second line plot in the second cell of the frame %Placing the first line plot in the first cell of the frame The below example present 2 line plots generated from one singe execution of the program with two different set of axes. Arranging multiple line plots in different subplot: Matlab supports to present the line plots generated in single execution, with distinct set of axes. %The minimum value of y-axis gets updated to -0.1 and maximum value for x-axis gets updated to 12. The limit values for the plots can be imposed on the axes using the command ‘axis’. Plot(x, y1,x,y2), xlabel('x-axis'), ylabel('y-axis'), title('Graph customisation'), %Adding x-label, y-label and title to the resultant plot The example defined below demonstrates the process of customization of the presentation of the graph by modifying the attributes given above. Axis square: Set of square plots can be generated. Axis equal: The plots can be created with a common scale factor and spaces for both the axis.į. Grid on: Makes the grid lines visible for the graph.Į. The customization of the lines drawn from single plot functions can be achieved by altering any of the attribute or any combination of the attributes described below:ĭ. The resultant plot consists of 2 sinusoidal line curves ‘y1’ and ‘y2’ having 2 different set of values ‘x1’ and ‘x2’, but share a common x-y plane.
0 Comments
Leave a Reply. |