Upcoming SlideShare
×

# CIV1900 Matlab - Plotting & Coursework

8,994
-1

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
8,994
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### CIV1900 Matlab - Plotting & Coursework

1. 1. CIV 1900Computer programming
2. 2. Contents for Lecture 5• Plotting capabilities in Matlab• Digital images and their construction• Image processing
3. 3. Matlab offers a rich graphicsenvironment and even if you do notfeel comfortable programming inMatlab you should make use of itsgraphics capabilities as it will allowyou to produce much higher qualitygraphs and figures than is possiblein Excel, for example.
4. 4. Pressure on the rib and in its lee
5. 5. Turbulent kinetic energy
6. 6. The most basic function you can use is togenerate scatterplots.Imagine that you have an array of data where thefirst column contains the year (1985-2010) inwhich a sample was taken and the second issome property of that sample.A basic piece of exploratory data analysis wouldbe to plot these data against one another.
7. 7. The Matlab command is “plot”i.e.plot(Data(:,1),Data(:,2))This defaults to producing a solid line in blue
8. 8. plot(Data(:,1),Data(:,2))We can make use of a shorthand for line symbols,line colours and line types to vary this. Someexamples:Colours Types Symbolsb = blue - = solid line o = circlesr = red : = dotted s = squarek = black -- = dashed d = diamondg = green ^ = triangle
9. 9. Plot(Data(:,1),Data(:,2),‟:ok‟)
10. 10. Plot(Data(:,1),Data(:,2),‟--^g‟,‟linewidth‟,2)
11. 11. We can improve the look of our plots by editingthe axis properties. Click Here
12. 12. Here I have edited the text size and the upper limitof the x-axis.
13. 13. Here I have defined the y-axis with a mathematicalexpression (you can‟t do this in Excel)
14. 14. Here I have converted the axes to log axes
15. 15. figureplot (Data(:,1),Data(:,2),:^m,linewidth,1.5)hold onplot (Data(:,1),Data(:,3),„--m,linewidth,1.5)
16. 16. figuresubplot(1,3,1:2)plot (Data(:,1),Data(:,2),:^m,linewidth,1.5)subplot(1,3,3)plot (Data(:,1),Data(:,3),„--m,linewidth,1.5)
17. 17. A 3D line plot:figureplot3(Data(:,1),Data(:,2),Data(:,3),‟k‟,‟linewidth‟,2)
18. 18. If we have an array of data we can plot it as a surface,where the x and y axes are given by the size of the arrayand the z-axis by the values in the array
19. 19. If we have an array of data we can plot itas a surface, where the x and y axes aregiven by the size of the array and the z-axis by the values in the array.surf(CIV1900_images{4})
20. 20. We may then rotate this
21. 21. We may then rotate this
22. 22. Images may also be displayed using the “image”or “imagesc” commands.Hopefully the previous example has highlightedthat an image is simply an array of digitalnumbers.This example was coloured but it was a “falsecolour” image. There was only level to the arrayand the colouring was applied in bands:high values (peaks) in red; low values (troughs) inblue.It might as well be a grey-scale image and we canmake it so by changing the “colormap”.
23. 23. surf(CIV1900_images{4})colormap(„gray‟)
24. 24. A “true colour” image (like a jpeg file) isconstructed rather differently. Instead of a singlelayer to the array, it has layers for each colour:Three layers for an RGB imageFour for a CMYK imageEach layer ranges from 0 to 255 and tells you howred or green or blue the colour is at that point.When they are all combined they give you thecolour at that location, which using a legend, youcan relate to properties of the image.
25. 25. Colour maps in Matlab by default range from 0 to63.The “image” command displays an image literallyrelating the values in the array to the colour map.The “imagesc” command rescales the values inthe array so that they fit the colour map.For example, the values in our image go from 0-255 so using “image” we would expect about 75%of the image to wash out as white
26. 26. figureimage(CIV1900_images{4})colormap(gray)
27. 27. figureimagesc(CIV1900_images{4})colormap(gray)
28. 28. figureimagesc(CIV1900_images{4})axis („image‟)colormap(gray)
29. 29. figurefor loop1=1:9 subplot(3,3,loop1) imagesc(CIV1900_images{loop1*3+4}) axis image colormap(gray)end
30. 30. Matlab provides a flexible tool for producinggraphics.This includes images, which are simply arrays ofnumbers (1 layer for grey-scale, more for truecolour).Image processing is an important area ofengineering science:Stress analysis on beams using photostresssystems;Particle Imaging velocimetry;Monitoring of land use change using remotesensing;Face or fingerprint recognition software, etc.
31. 31. The Coursework Sobel Filtering – Edge Detection
32. 32. The Coursework The convolution integral
33. 33. The Coursework Filter Image
34. 34. The Coursework
35. 35. The Coursework
36. 36. The Coursework Sobel X Sobel Y