Vg101 Recitation I TAs
Vg101 Recitation I TAs
Agenda Vectors matrices Flow control Example1 (addGeneral) ·Plotting with Matlab ·Example2(regPloy)
• Vectors & matrices • Flow control • Example1 (addGeneral) • Plotting with Matlab • Example 2 (regPloy) Agenda
Operators (arithmetic) addition subtraction multiplication division power franspose ★ element-by-element mult element-by-element div element-by-element power
Operators (arithmetic) + addition - subtraction * multiplication / division ^ power ’ transpose .* element-by-element mult ./ element-by-element div .^ element-by-element power
Generating Vectors y a:step:b y linspace(a,b,n) y logspace(a,b,n) >>y logspace(1,2,6) y= 10.0000 15.8489 25.1189 39.8107 63.0957100.0000
Generating Vectors • y = a:step:b • y = linspace(a, b, n) • y = logspace(a, b, n)
Generating Matrices zeros(M,N)MxN matrix of zeros -ones(M,N) MxN matrix of ones ·rand(M,n) MxN matrix of uniformly distributed random numbers on (0,1) ·Direct define y=[123;456;789] y=[1,2,3:4,5,6,7,8,9]
Generating Matrices • zeros(M,N) MxN matrix of zeros • ones(M,N) MxN matrix of ones • rand(M,N) MxN matrix of uniformly distributed random numbers on (0,1) • Direct define y = [1 2 3;4 5 6;7 8 9] y = [1,2,3;4,5,6;7,8,9]