Lecture4 - Initializing Variables ■ Explicitly list the...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Initializing Variables ■ Explicitly list the values ■ reads from a data file ■ uses the colon (:) operator ■ reads from the keyboard A = [1; 3; 5; 10]; B = [1 3 5; -6 4 -1] C = [2 3 5 1; 0 1 … (continuation) 1 -2; 3 5 1 -3] E = [A; 1; A]; F = [C(2,3); A] - = -- = 4 1 1 2 1 5 2 F 4 1 1 2 3 1 1 5 2 1 C Colon Operator ■ Creating new matrices from an existing matrix C = [1,2,5; -1,0,1; 3,2,-1; 0,1,4] F = C(:, 2:3) = [2,5; 0,1; 2,-1; 1,4] -- = -- = 1 2 3 1 1 E 4 1 1 2 3 1 1 5 2 1 C Colon Operator ■ Creating new matrices from an existing matrix C = [1,2,5; -1,0,1; 3,2,-1; 0,1,4] E = C(2:3,:) = [-1 0 1; 3 2 -1] Colon Operator ■ Creating new matrices from an existing matrix C = [1,2,5; -1,0,1; 3,2,-1; 0,1,4] G = C(3:4,1:2) = [3,2; 0,1] = -- = 1 2 3 G 4 1 1 2 3 1 1 5 2 1 C Colon Operator ■ Variable_name = a:step:b time = 0.0:0.5:2.5 time = [0.0, 0.5, 1.0, 1.5, 2.0, 2.5] ■ Negative increment values = 10:-1:2 values = [10, 9, 8, 7, 6, 5, 4, 3, 2] linspace Function ■ linspace(x1, x2) gives 100 evenly spaced values between x1 and x2 x = linspace(x1, x2) ■ linspace(a, b, n) generate n equally spaced points between a and b x = linspace(a, b, n) » linspace(0,2,11) ans = Columns 1 through 7 0 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 Columns 8 through 11 1.4000 1.6000 1.8000 2.0000 logspace Function ■ logspace( a, b, n ) generates a logarithmically equally spaced row vector x = logspace(a,b,n) ■ logspace(a, b) generates 50 logarithmically equally spaced points x = logspace(a,b) » logspace(-4,2,7 ) ans = 0.0001 0.0010 0.0100 0.1000 1.0000 10.0000 100.0000 Special Matrices = = = = 1 1 1 1 1 1 1 1 ones(2,4) 1 1 1 1 1 1 1 1 1 ) 3 ( ones zeros(3,2) 1 1 1 ) 3 ( eye b a b a b a b a a b b a b a b a b a ab a a b a a b- + ±- + = ÷--- ; n subtractio and Addition...
View Full Document

This note was uploaded on 09/05/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Page1 / 28

Lecture4 - Initializing Variables ■ Explicitly list the...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online