CS 100 M Lecture 13 - 13. Strings Operations Subscripting...

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

View Full Document Right Arrow Icon
13. Strings Operations Subscripting Concatenation Search Numeric-String Conversions Built-Ins: int2str,num2str, str2double
Background image of page 1

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

View Full DocumentRight Arrow Icon
Previous Dealings N = input( ‘ Enter Degree: ’) title(‘ The Sine Function ’) disp( sprintf(‘N = %2d’,N) )
Background image of page 2
A String is an Array of Characters ‘Aa7*>@ x!’ A a 7 * > @ x ! This string has length 9.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Why Important 1. Numerical Data often encoded as strings 2. Genomic calculation/search
Background image of page 4
Numerical Data is Often Encoded in Strings For example, a file containing Ithaca weather data begins with the string W07629 N4226 Longitude: 76 o 29’ West Latitude: 42 o 26’ North
Background image of page 5

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

View Full DocumentRight Arrow Icon
What We Would Like to Do W07629 N4226 Get hold of the substring ‘07629’ Convert it to floating format so that it can be involved in numerical calculations.
Background image of page 6
Format Issues 9 as an IEEE floating point number: 9 as a character: 0100000blablahblah01001111000100010010 01000otherblabla Different Representation
Background image of page 7

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

View Full DocumentRight Arrow Icon
Genomic Computations Looking for patterns in a DNA sequence: ‘ATTCTGACCTCGATC’ ACCT
Background image of page 8
Genomic Computations Quantifying Differences: ATTCTGACCTCGATC ATTGCTGACCTCGAT Remove?
Background image of page 9

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

View Full DocumentRight Arrow Icon
Working With Strings
Background image of page 10
Strings Can Be Assigned to Variables S = ‘N = 2’ N = 2; S = sprintf(‘N = %1d’,N) ‘N = 2’ S
Background image of page 11

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

View Full DocumentRight Arrow Icon
Strings Have a Length s = ‘abc’; n = length(s); % n = 3 s = ‘’; % the empty string n = length(s) % n = 0 s = ‘ ‘; % single blank n = length(s) % n = 1
Background image of page 12
Concatenation This: S = ‘abc’; T = ‘xy’ R = [S T] is the same as this: R = ‘abcxy’
Background image of page 13

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

View Full DocumentRight Arrow Icon
Repeated Concatenation This: s = ‘’; for k=1:5 s = [s ‘z’]; end is the same as this: z = ‘zzzzz’
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/23/2008 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell University (Engineering School).

Page1 / 47

CS 100 M Lecture 13 - 13. Strings Operations Subscripting...

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

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