Download presentation
Presentation is loading. Please wait.
Published byAnastasia Shaw Modified over 9 years ago
1
EGR 115 Introduction to Computing for Engineers MATLAB Basics 4: Intro to Plotting Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers
2
Lecture Outline Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Intro to Plotting Slide 2 of 11
3
MATLAB basics Intro to Plotting: Plot Function Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Presenting data in graphical form is very useful. It is quite easy to plot data in MATLAB The format for the “plot” command is: >> plot(indep_var, dep_var) o Both the independent variable (say, x) and dependent variable (say, y(x)) should be the same size. >> x = [0:0.1:3]; % Independent variable >> y = round(x); % Dependent variable >> plot(x, y) Dep Var Indep Var Slide 3 of 11
4
MATLAB basics Intro to Plotting: Plot Function Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Controlling the style of the line plot Changing the line color (to red) >> plot(x, y, 'r'); % Choices: c, y, m, k, r, g, b Change the linestyle to dashed >> plot(x, y, '--');% Dashed linestyle Change the line marker to ‘+’ >> plot(x, y, '+');% Marker set to ‘+’ Plot with a magenta colored dotted line and square symbols Slide 4 of 11
5
MATLAB basics Intro to Plotting: Plot Function Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Superimposing Multiple Plots >> z = floor(x); >> plot(x, y, 'm:s', x, z, 'r-'); >> title('Multiple Plots') >> xlabel('x') >> ylabel('Magnitude') >> legend('round(x)', 'floor(x)'); Multiple Plot Windows Precede the plot(..) command with the command “figure” >> figure, plot(…) o This will create a new figure window!! Slide 5 of 11
6
MATLAB basics Additional Info Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Slide 6 of 11
7
MATLAB basics Additional Info Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Slide 7 of 11
8
MATLAB basics Additional Info Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers = 18.167 Slide 8 of 11
9
MATLAB basics Additional Info Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Slide 9 of 11
10
MATLAB basics Additional Info Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers Slide 10 of 11
11
Next Lecture Wednesday 10 Sept 2014 EGR 115 Introduction to Computing for Engineers MATLAB Applications Vector math Slide 11 of 11
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.