week09 - Rutgers University School of Engineering Fall 2011...

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

View Full Document Right Arrow Icon
Rutgers University School of Engineering Fall 2011 14:440:127 - Introduction to Computers for Engineers Sophocles J. Orfanidis ECE Department orfanidi@ece.rutgers.edu week 9
Background image of page 1

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

View Full DocumentRight Arrow Icon
Week 1 Week 2 Week 3 - Matrices (ch. 4) Week 4 - Plotting – 2D and 3D plots (ch. 5) Week 5 - User-defined functions (ch. 6) Week 6 - Input-output processing (ch. 7) Week 7 Week 8 - Matrix algebra – solving linear equations (ch. 9) Week 9 - Strings, structures, cell arrays (ch. 10) Week 10 - Symbolic math (ch. 11) Week 11 - Numerical methods – data fitting (ch. 12) Week 12 – Selected topics Weekly Topics Textbook: H. Moore, MATLAB for Engineers , 2 nd ed., Prentice Hall, 2009
Background image of page 2
Strings, Structures, Cells • characters and strings • concatenating strings • using num2str • comparing strings with strcmp • structure arrays • converting structures to cells • cell arrays • cell vs. content indexing varargin, varargout • multi-dimensional arrays
Background image of page 3

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

View Full DocumentRight Arrow Icon
MATLAB Data Classes Character Floating Point single precision double precision Logical Numeric Symbolic Cell Structure More Classes Cell and Structure arrays can store different types of data in the same array Integer signed unsigned Java classes function handles user-defined classes
Background image of page 4
Characters and Strings Strings are arrays of characters. Characters are represented internally by standardized numbers, referred to as ASCII (American Standard Code for Information Interchange) codes. see Wikipedia link: ASCII table >> c = 'A' c = A >> x = double(c) x = 65 % ASCII code for 'A' >> char(x) ans = A >> class(c) ans = char char() creates a character string >> doc char >> doc class
Background image of page 5

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

View Full DocumentRight Arrow Icon
s is a row vector of 8 characters >> s = 'ABC DEFG' s = ABC DEFG >> x = double(s) x = 65 66 67 32 68 69 70 71 >> char(x) ans = ABC DEFG >> size(s) ans = 1 8 >> class(s) ans = char ASCII codes convert ASCII codes to characters >> s(2), s(3:5) ans = B ans = C D
Background image of page 6
Concatenating Strings s = ['Albert', 'Einstein'] s = AlbertEinstein >> s = ['Albert', ' Einstein'] s = Albert Einstein >> s = ['Albert ', 'Einstein'] s = Albert Einstein >> size(s) ans = 1 15 preserve leading and trailing spaces >> doc strcat >> doc strvcat >> doc num2str >> doc strcmp >> doc findstr
Background image of page 7

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

View Full DocumentRight Arrow Icon
Concatenating Strings s = strcat('Albert ', 'Einstein') s = AlbertEinstein >> s = strcat('Albert', ' Einstein') s = Albert Einstein >> fmt = strcat(repmat('%8.3f ',1,6),'\n') fmt = %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n strcat strips trailing spaces but not leading spaces use repmat to make up long format strings for use with fprintf
Background image of page 8
s = ['Apple'; 'IBM'; 'Microsoft']; ??? Error using ==> vertcat CAT arguments dimensions are not consistent. s = ['Apple
Background image of page 9

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

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

This document was uploaded on 11/04/2011 for the course ENGINEERIN 440 at Rutgers.

Page1 / 43

week09 - Rutgers University School of Engineering Fall 2011...

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