Plot Multiple Lines Using Matrices Copy Code Copy Command Create matrix X containing three rows of x-coordinates. Create matrix Y containing three rows of y-coordinates. Get t = 0:pi/500:pi; X(1,:) = sin(t).*cos(10*t); X(2,:) = sin(t).*cos(12*t); X(3,:) = sin(t...
How to Plot Multiple Lines on the Same Figure Learn how to plot multiple lines on the same figure using two different methods in MATLAB®. We’ll start with a simple method for plotting multiple lines at once and then look at how to plot additional lines on an already existing figure. ...
Plot Multiple Lines Copy Code Copy Command Define x as 100 linearly spaced values between −2π and 2π. Define y1 and y2 as sine and cosine values of x. Create a line plot of both sets of data. Get x = linspace(-2*pi,2*pi); y1 = sin(x); y2 = cos(x); figure plot(...
Plot Multiple Lines Copy Code Copy Command Define x as 100 linearly spaced values between and . Define y1 and y2 as sine and cosine values of x. Create a line plot of both sets of data. Get x = linspace(-2*pi,2*pi); y1 = sin(x); y2 = cos(x); figure plot(x,y1,x,y2...
Plot Multiple Lines Copy Code Copy Command Define x as 100 linearly spaced values between −2π and 2π. Define y1 and y2 as sine and cosine values of x. Create a line plot of both sets of data. Get x = linspace(-2*pi,2*pi); y1 = sin(x); y2 = cos(x); figure plot(...
x = linspace(0,2*pi,100); y = sin(x); plot(x,y) Label the axes and add a title. xlabel('x') ylabel('sin(x)') title('Plot of the Sine Function') Plot Multiple Lines By default, MATLAB clears the figure before each plotting command. Use thefigurecommand to open a new figure...
Plot Multiple Lines Copy Code Copy Command Define x as 100 linearly spaced values between −2π and 2π. Define y1 and y2 as sine and cosine values of x. Create a line plot of both sets of data. Get x = linspace(-2*pi,2*pi); y1 = sin(x); y2 = cos(x); figure plot(...
Plot Multiple Lines Using Matrices Create matrixXcontaining three rows ofx-coordinates. Create matrixYcontaining three rows ofy-coordinates. t = 0:pi/500:pi ; X(1,:) = sin(t).*cos(10*t) ; X(2,:) = sin(t).*cos(12*t)
You have to use colororder(Colormap Name) with the desired color map. Then with one plot, you can use all desired colors in the appropriate order. Actually one can change colororder after data is plotted.
两个函数的格式不同:\x0d\x0aplot(X,Y,S); % X,Y为坐标,画出一个点,S为其它属性(颜色,点的大小等)。\x0d\x0aline([X1 X2],[Y1 Y2],S); %点A(X1,Y1)和点B(X2 Y2)之间画一条直线,S为其它属性(颜色,线的粗细等)。\x0d\x0a详细资料可以在matlab主面板里输入 ...