CSC115: Matlab Special Session
description
Transcript of CSC115: Matlab Special Session
![Page 1: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/1.jpg)
CSC115: Matlab Special SessionDr. Zhen JiangComputer Science DepartmentWest Chester University
![Page 2: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/2.jpg)
Class informationTextbook
◦Hanselman & Littlefield, “Mastering Matlab 7”, Prentice Hall, Upper Saddle River, NJ, 2005.
![Page 3: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/3.jpg)
![Page 4: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/4.jpg)
Example on Page 6◦Variable◦Keyword (reserved word)◦;◦Calculation◦% (comment)◦,◦error
![Page 5: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/5.jpg)
![Page 6: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/6.jpg)
<File> <new>Or the direct access from the
icon “blank”
![Page 7: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/7.jpg)
![Page 8: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/8.jpg)
Input / OutputParameter input Page 33
![Page 9: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/9.jpg)
![Page 10: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/10.jpg)
Xls input (the easiest one)◦Sample xls input file
Page 250Also available at
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/xlsread.html
![Page 11: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/11.jpg)
![Page 12: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/12.jpg)
![Page 13: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/13.jpg)
Something must knowPage 39
◦How to use the readout n?
![Page 14: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/14.jpg)
![Page 15: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/15.jpg)
![Page 16: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/16.jpg)
Apply an operation on every unit in the array
Page 47` (especially useful to handle
different input format, see the discussion later)
![Page 17: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/17.jpg)
![Page 18: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/18.jpg)
Standard arrays, page 54◦Ones, zeros, size, eye, rand, randn,
diag◦Repmat(pi, 3, 4)
![Page 19: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/19.jpg)
Array sorting, search, page 73
![Page 20: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/20.jpg)
![Page 21: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/21.jpg)
Find(a>4, 2, ‘first’)◦Page 189, such as a filter to discard
NaN or InFMaxMinSize
![Page 22: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/22.jpg)
![Page 23: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/23.jpg)
![Page 24: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/24.jpg)
Manipulation * , page 82 (optional)
![Page 25: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/25.jpg)
Multidimensional array◦1-d => 2-d => 3-d, page 98◦3-d => 2-d => 1-d, page 99◦Reshape(page 57), cat(page 101),
flipdim, shiftdim, permute◦Their search and sorting, such as a
3d array sorted in one dimension.
![Page 26: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/26.jpg)
[p, q]◦[ p q ]◦Or cat (2, p, q)
[p; q]◦Or cat (1, p, q)
![Page 27: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/27.jpg)
Output◦Standard output◦Disp(), page 162◦Sprintf, page 168◦Plot, page 276
![Page 28: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/28.jpg)
![Page 29: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/29.jpg)
![Page 30: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/30.jpg)
Other inputs◦Sample plain text file
Help fileformats, page 253Tip: Try to avoid using low level
file I/O
![Page 31: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/31.jpg)
![Page 32: CSC115: Matlab Special Session](https://reader033.fdocuments.us/reader033/viewer/2022051517/56813dd0550346895da7993f/html5/thumbnails/32.jpg)