This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: %Matrix indexing %Guess what you will get before trying these: a(1,1) a(1) % these are strange, until you realize that matlab keeps data by columns a(1,2) a(2,1) a(2) a(1,3) a(3,1) % error here a(3) % this is a(i,j) for what i,j? This is a strange "feature" often accessed by mistake f(1:2,1:2) % submatrices e(1:2,2:3) g(2:3,2:3) diag(g) g(1,:) % colon shortcuts. Note the similarities and differences for transposes g(:,1) a(:,1) b(1,:) a(1,:) b(:,1) a(:,:) a(:) b(:) e(2,3) = 5 %Changing parts of a matrix e(3,2) = 6 e e(1:2,1:2) = h'; e g(2,:) = 1; g g(2,:) = ; %check this one out setting a row to an empty matrix size(g) g...
View Full Document
This note was uploaded on 03/22/2009 for the course COMP 116 taught by Professor Stotts during the Spring '08 term at UNC.
- Spring '08
- C Programming