Académique Documents
Professionnel Documents
Culture Documents
x = linspace(0,2*pi,100);
y = sin(x);
figure
plot(x,y)
Define xand y.
x = linspace(0,2*pi,25);
y = sin(x);
Create a stairstep plot of yversus x. Open a new figure window using the figurecommand. If you do not open a new figure window, then by default, MATLAB® clears existing
graphs and plots into the current figure.
http://in.mathworks.com/help/matlab/creating_plots/using-high-level-plotting-functions.html 1/5
8/28/2015 Create 2-D Graph and Customize Lines - MATLAB & Simulink - MathWorks India
x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = sin(x-pi/4);
figure
plot(x,y1,x,y2)
x = linspace(0,2*pi,100);
y = sin(x);
figure
plot(x,y,'--')
http://in.mathworks.com/help/matlab/creating_plots/using-high-level-plotting-functions.html 2/5
8/28/2015 Create 2-D Graph and Customize Lines - MATLAB & Simulink - MathWorks India
Plot the first sine wave with a dashed line using '--'. Plot the second sine wave with a dotted line using ':'.
x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = sin(x-pi/4);
figure
plot(x,y1,'--',x,y2,':')
Plot a sine wave with a green dashed line using '--g'. Plot a second sine wave with a red dotted line using ':r'. The elements of the line specification strings can appear in
any order.
x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = sin(x-pi/4);
figure
plot(x,y1,'--g',x,y2,':r')
Define xas 25 linearly spaced values between 0 and . Plot the first sine wave with a green dashed line and circle markers using '--go'. Plot the second sine wave with a
red dotted line and star markers using ':r*'.
http://in.mathworks.com/help/matlab/creating_plots/using-high-level-plotting-functions.html 3/5
8/28/2015 Create 2-D Graph and Customize Lines - MATLAB & Simulink - MathWorks India
x = linspace(0,2*pi,25);
y1 = sin(x);
y2 = sin(x-pi/4);
figure
plot(x,y1,'--go',x,y2,':r*')
Define the data xand y. Plot the data and display a star marker at each data point.
x = linspace(0,2*pi,25);
y = sin(x);
figure
plot(x,y,'*')
See Also
contour| LineSpec (Line Specification)| linspace| loglog| plot| plotyy| scatter| semilogx| semilogy| stairs| stem
Related Examples
• Add Title, Axis Labels, and Legend to Graph
• Change Axis Limits of Graph
• Change Tick Marks and Tick Labels of Graph
http://in.mathworks.com/help/matlab/creating_plots/using-high-level-plotting-functions.html 4/5
8/28/2015 Create 2-D Graph and Customize Lines - MATLAB & Simulink - MathWorks India
http://in.mathworks.com/help/matlab/creating_plots/using-high-level-plotting-functions.html 5/5