MATLAB Examples - Plotting
[Pages:18]MATLAB Examples
Plotting
Hans-Petter Halvorsen, M.Sc.
>> x = 0:0.1:2*pi; >> y = sin(x); >> plot(x,y)
Plotting
>> x = 0:0.1:2*pi; >> y = sin(x); >> y2 = cos(x); >> plot(x,y, x,y2)
... >> plot(x,y,'r*', x,y2,'g+')
Plotting
Plotting functions:
Name plot
Description Create a Plot
figure grid on/off title
Define a new Figure/Plot window Create Grid lines in a plot Add Title to current plot
xlabel ylabel
Add a Label on the x-axis Add a Label on the x-axis
axis hold on/off legend
subplot
Set xmin,xmax,ymin,ymax Add several plots in the same Figure
Create a legend in the corner (or at a specified position) of the plot Divide a Figure into several Subplots
>> x=0:0.1:2*pi; >> y=sin(x); >> plot(x,y) >> title('Plot Example') >> xlabel('x') >> ylabel('y=sin(x)') >> grid on >> axis([0,2*pi,-1,1]) >> legend('Temperature')
Plotting
Given the following Rain Data for a given Week (Monday to Sunday):
Day
Rain Amount
Monday Tuesday
2,1 mm 10 mm
We want to plot these values
Wednesday 9,7 mm
Thursday
6,2 mm
Friday
2,5 mm
Saturday
0 mm
Sunday
8,3 mm
Solution
Day
Rain
Amount
Monday
2,1 mm
Tuesday 10 mm
Wednesday 9,7 mm
Thursday 6,2 mm
Friday
2,5 mm
Saturday 0 mm
Sunday
8,3 mm
Plotting
x = [2.1, 10, 9.7, 6.2, 2.5, 0, 8.5] >> plot(x, 'o')
Plotting
Given the following function (-10 10 ):
= 2* + 3 + 1
We will: ? Plot this function
? Use the Plot to find out: - For which value of is () = 0? - What is (5) =?
Plot of Dynamic System
Given the autonomous system (differential equation): =
where = - 4 ,where is the time constant
5
The solution for the differential equation is: = 9:;
Set = 5 and the initial condition (0) = 1
Create a Script in MATLAB (.m file) where you plot the solution () in the time interval 0 25 Add Grid, and proper Title and Axis Labels to the plot.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- matlab workbook stanford university
- matlab examples plotting
- a practical time series tutorial with matlab
- matlab applications in chemical engineering
- introduction to matlab for engineering students
- ee 101 lab 6 matlab intro montana state university
- week 2 plotting in matlab
- data plotting with matlab and plot1
- short introduction to matlab
- chapter 6 plots
Related searches
- plotting with pandas
- plotting cdf in python
- plotting text file with dates with pandas
- plotting worksheets for writers
- plotting graphs on excel
- plotting fractions on number line calculator
- plotting numbers on number line
- data plotting tools
- free data plotting software
- plotting fractions on a number line
- plotting inequalities on number lines
- plotting lines with equations