Presentation is loading. Please wait.

Presentation is loading. Please wait.

IT1005 Lab session on week 6 (2 nd meeting). Lab 2 - Recap By now, you must ensure that you are familiar with Matlab environments: – Matlab main window,

Similar presentations


Presentation on theme: "IT1005 Lab session on week 6 (2 nd meeting). Lab 2 - Recap By now, you must ensure that you are familiar with Matlab environments: – Matlab main window,"— Presentation transcript:

1 IT1005 Lab session on week 6 (2 nd meeting)

2 Lab 2 - Recap By now, you must ensure that you are familiar with Matlab environments: – Matlab main window, M-File Editor, Command Window, Workspace, Figure Window, Docking, etc. – Matlab debugger, breakpoint, stepping functions, looking at workspace during stepping, ‘go to cursor’, adjusting program based on the error messages, etc. Remember that you can always just select Matlab codes using ‘Select tool’ in Adobe Acrobat, then do copy-paste to Matlab rather than typing it all again. – For lab assignments, for trying codes in lecture notes, etc.

3 Symbols and Keyboard Locations SymbolEnglish NameKeyboard LocationMatlab example :ColonSHIFT+two keys on the left of [Enter]A = 1:5 ;SemicolonTwo keys on the left of [Enter]A = [1;2;3] `Apostrophe 1One key on the left of key 1NOT valid! ‘Apostrophe 2One key on the left of [Enter]A = ‘hello’ []Square bracketAbove [Enter]A = [1 2 3] &AmpersandSHIFT+key 7true && true |BarSHIFT+one key above [ENTER]false || true ~TildeSHIFT+one key one the left of key 1~ false The other keys should be quite straightforward… http://en.wikipedia.org/wiki/Keyboard_layout#US

4 Review on Array/Vector/Matrix Creation – mat = [], repmat, ones, zeros, eye, diag, rand, etc Accessing elements/indexing (index start from 1!) – mat(indices), the usage of ‘:’, mat([indices 1 … indices n ]) Manipulation: add, edit, delete row/col, sort, find – mat(:,x) = y Operation: +, -, *, /,.*,./ – matA op matB, mat op scalar (scalar expansion) Multidimensional array: 3-D… – We seldom go beyond 3D…

5 Quick Test Simple test to about array: 1.Create an array of size 4*5 with all ‘1’ (then all ‘0’). 1.Try repmat, manual creation, using [1;1;1;1]*[1 1 1 1 1] =) 2.Compute this: [1 2].* [2 1] = [3 4] [2 1] 1.Change.* to *,./, /, +, or - 3.Create this array [1 2 3; 4 5 6; 7 8 9], then perform these operations: 1.Change the 2 nd row to 100 90 80! 2.Change the 3 rd col to 20 10 0! 3.Change the main diagonal to all zeros!

6 Relational and Logical Operations Matlab relational operations –, =, ==, ~= – relational operations on array  the result is array – floating-point imprecision  use eps Logical operators – &, |, ~, &&, || – short circuit

7 Quick Test Simple test to about relational/logical operations: – How to make these statements produce ans = 1 – You can only supply ONE single operator or MATLAB function to replace ‘…’ 1.10+30*2-5/4 … 2*5-10 2.sin(pi) == 0? 3.… ( [10 20 30] / 10... [1 2 3] ) 4.10 > 20... 5 … 2 5.10 > 5 … 5 > 2 6.… … 10 > 20 && 5 < 2 …

8 Lab 3 – Free and Easy Time Now, you are free to explore Matlab, especially to find answers for Lab 3 For those who have done Lab 3, try this extra challenges! The solution is at the end of this session – There is a land of size 3m*5m – The height of each square meter on that land is known: [1 2 3 4 5; 2 3 4 5 6; 7 7 7 7 7] above sea level (denoted in meter). – A house of size 3*5 is going to be built there. – Before building it, the land must be leveled! – We want the land to have height 5m above sea level. – Question: what is the minimum amount of soil (in cubic meter) that must be added (or perhaps removed) in order to make this land flat? – Hint: explore array operations, Matlab function ‘sum’, and ‘mesh’ or ‘surf’!

9 Lab 3 Marking + Midterm Test I will be away – @ Jakarta, Indonesia during mid semester break – 22 Feb night – 2 March Lab 3 marks will be available on 3 or 4 March. – Will not be as fast as Lab 0/1 last week. If you have any questions, try IVLE forum first, ask your class mates, or ask Colin. – I will occasionally check my emails from home, but will not be able to reply that fast! – Or ask on Monday morning, before your Mid-term exam!

10 Remember This! E-mail answers to: stevenhalim at gmail.com With subject header: – “IT1005-LabGroupID” “FullName”, e.g. IT1005-7A StevenHalim – Mr Gmail will sort your emails for me =) Try to submit your answers ONCE – Do not submit again to fix some minor mistakes! Shorter (but correct) answers ~ better marks =) Remember, I have ~100 emails/week !


Download ppt "IT1005 Lab session on week 6 (2 nd meeting). Lab 2 - Recap By now, you must ensure that you are familiar with Matlab environments: – Matlab main window,"

Similar presentations


Ads by Google