What you seem to be doing is a simulation in a simulation. Any input to a Scope that is a vector is treated as different variables having a certain value at time t, so to say. If it is then Simulink will plot many lines since you output a vector. Is this model you showed part of a bigger model? If not than doing this the way you are makes no sense in Simulink, you could've just used Matlab. Phase 2: Editing the display of the plot using attributes from the chart line object ‘p’.A quick look tells me that it seems to be possible to make a model for this using simulink blocks and not a matlab function.
MATLAB SIMULINK PLOT CODE
The below code is written to generate two linear curves and edit the display of the graphs by altering the attributes of the chart line object. The generated plot gets assigned to a chart line object and its display gets customized by altering the attributes from the storing chart line object. Matlab extends its feature in 2D line plot to customize the plot presentation through the execution even after the plot is generated. Plot(x,y1,x,y2,'-o','MarkerIndices',1:1:50)Ĭustomizing the presentation of the lines after creation of the plot. The below example generate 2 line plots and one plot is highlighted with marker symbol ‘-o’. In case of graph containing lines more than 3 and having overlapped presentation, it helps to determine which data point belongs to which plot. Markers helps to point out distinct data points on the plotted line to figure out the exact values calculated from the function. The below code snippet generates 6 lines for the function defined by ‘y’ which is function of the looping variable ‘x’.ĭisplaying markers for specific data points for the lines. 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.