Lab07 - Riti Gupta 20249537 Section 22 Lab 07 1.1 Character Arrays > A='cat A= cat > B=[A'erpillar B= caterpillar > C=B C= caterpillar >

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

View Full Document Right Arrow Icon
Riti Gupta 20249537 Section 22 Lab 07 1.1 Character Arrays >> A='cat' A = cat >> B=[A, 'erpillar'] B = caterpillar >> C=B C = caterpillar >> C(1:length(A))='dog' C = dogerpillar >> class(C) ans = char >> B==C ans = Columns 1 through 10 0 0 0 1 1 1 1 1 1 1 Column 11 1 >> strcmp(B,C) ans = 0 1.2 Cell Arrays >> A={54 'cat'} A = [54] 'cat' >> B=A(1) B = [54] >> C=A{1} C = 54
Background image of page 1

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

View Full DocumentRight Arrow Icon
ans = cell >> class(C) ans = double The difference between B and C is that B is a cell whereas C is a number, or double. Using the squiggly bracket tells MATLAB to take the components inside of the cell. In B, since only parentheses are used, MATLAB tells you what the first object of A is; a cell. You need squiggly brackets to open up the cell to retrieve what is inside of it. >> D={A 'dog' B} D = {1x2 cell} 'dog' {1x1 cell} a. >> D{2} ans = dog b. >> D{1}{2}(3) ans = t 1.3 Structure Arrays >> student student = 1x2 struct array with fields: name section >> student(1) ans = name: 'Chet' section: 14 >> student.name ans = Chet ans = Trevor >> student(2).section ans = 15 >> class(student)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/01/2009 for the course ENGIN 7 taught by Professor Horowitz during the Spring '08 term at University of California, Berkeley.

Page1 / 7

Lab07 - Riti Gupta 20249537 Section 22 Lab 07 1.1 Character Arrays > A='cat A= cat > B=[A'erpillar B= caterpillar > C=B C= caterpillar >

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

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