# 23 - vec =[1 3 2 4-Structures SA = struct'field1...

This preview shows pages 1–2. Sign up to view the full content.

Recitation CS 1371 9/23/08 ----make function that produces an array that has the rows flipped and only the odd columns. function yarr1 = flipOdds(yarr) yarr1 = yarr(end:-1:1, 1:2:end) rows columns --------------------------------------------------------- A = [2 6] [4 5] size(a) = [2 2] [r,c] = size(A) %switches the rows and columns of each element transpose(A) = [2 4] [6 5] A = [2 5;4 6] **can't take out any specific elements, only full rows or columns A(2,:) = [ ] **colon signifies all Array Concatenation A = [2 5 5 ; 6 3 10] B = [5 10 10 ; 6 7 11] C = [A B] regular (put B to the right of A) C = [A ; B] vertical concatenation (put B under A) D = [5 6 ; 10 5] E = [6 5 ; 10 11] F = [D E(: , 2)] = [5 6 5 ; 10 5 11] --------------------------------------------- Array Linearizing 1 3 | |

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

View Full Document
G = [2 6] [5 10] | | 2 4 vec = [1 2] [3 4] vec = vec(:)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vec = [1 3 2 4]-------------------------------------------Structures SA = struct('field1', value, 'field2', value2) 'field1' : value 'field2' : value2 Phonebook = struct('Name', John, 'Phone', '4045556543') Name : John Phone : 404 . .... structure.field = value Phonebook.name = 'John' Phonebook.phone = '4045556543' Phonebook(2).name = 'Kathy' Phonebook(2).phone = '-----------------------------------------**remove field SA = rmfield(SA, 'field') Phonebook = rmfield(Phonebook, 'Phone') SA(1) = setfield(SA(1), 'field', value) Phonebook(1) = setfield(Phonebook(1), 'Phone', '911') Names = {Phonebook.name} outputs all name into an array *******(single apostrophe ' after array transposes it from rows to columns******* SA = cell2struct(CA, 'fields', dimension)...
View Full Document

## This note was uploaded on 10/20/2008 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.

### Page1 / 2

23 - vec =[1 3 2 4-Structures SA = struct'field1...

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

View Full Document
Ask a homework question - tutors are online