Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB

Similar presentations


Presentation on theme: "CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB"— Presentation transcript:

1 CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Graphics

2 Basic 2-D Graphs Try out the following (if copy from this slide, retype single quotes in MatLab) y=[1,3,1,3,2,4]; plot(y) plot(rand(1,20)) x=0:pi/40:4*pi; plot(x, sin(x)) plot([0 4], [1 3]) gtext(‘notes’) %place cursor on the graph to insert notes grid title(‘x square’) xlabel(‘horizontal’) ylabel(‘vertical’) help plot %documentation about plot()

3 Basic 2-D Graphs There are different ways of drawing multiple plots on the same set of axes. Axes may be scaled as new graphs are added. Method one hold … hold Method two plot(x1, y1, x2, y2, x3, y3, …) %each pair will be a different color plotyy() gives you two y labels, on left and right

4 Basic 2-D Graphs Method three
plot(x,y) where x and y are both matrices, or one is a vector and one is a matrix

5 Basic 2-D Graphs Line styles, markers and color plot(x,y, '--')
plot(x,y, ‘o') plot(x,y, 'o--') plot(x,y, 'om--') You can also format these properties in the figure window.

6 Basic 2-D Graphs subplot
Divide the figure window into several sections with each section having a different plot E.g. subplot(2,3,1) %divide the figure into 2 rows and 3 columns and place the current plot into the first section subplot(1,1,1) to go back

7 Basic 2-D Graphs figure(h) where h is an integer creates a new figure window or makes figure h the current figure. Subsequent plots are drawn in the current figure. E.g. figure(2) clf clears the current figure window. cla deletes all the plots and text from the current axes, leaves only the x- and y-axes and their associated information.

8 Basic 2-D Graphs Other type of graphs

9 Basic 2-D Graphs Other type of graphs

10 3-D PLOTS Draw 3-D plots either in lines or as various types of surfaces. plot3(x, y, z) plot3(rand(1,10), rand(1,10), rand(1,10))

11 3-D PLOTS Mesh Surfaces E.g. z = x^2 – y^2 Step 1, set up the grid in the x-y plane over which the surface is to be plotted. meshgrid function can be used: [x,y] = meshgrid(0:5); Result: columns of matrix x hold the x co-ordinates of the points in the grid, while the rows of y hold the y co-ordinates. Note: the finer the grids, the finer the mesh surface. E.g. [x,y] = meshgrid(0:0.2:5);

12 3-D PLOTS Mesh Surfaces E.g. z = x^2 – y^2
Step 2, generate surface points z Step3, plot the surface mesh(z) or mesh(x,y,z) surf(z) or surf(x,y,z)

13 3-D PLOTS Mesh Surfaces E.g. Mexican Hat
Note: the finer the grids, the finer the mesh surface. E.g. [x,y] = meshgrid(-8:0.1:8);

14 3-D PLOTS Contour Plots E.g. Initial heat distribution over a steel plate

15 Image Processing Image enhancement – removing noise and sharpening an image Image segmentation – isolating objects of interest and gathering statistics Image registration – aligning multiple images from different camera sources 

16 Image Processing Additional videos – Image processing tool box
Rapid development of image processing algorithms Medical image processing with Matlab Matlab for life scientists


Download ppt "CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB"

Similar presentations


Ads by Google