Agenda

%

% Final Exam Week Details

% CS1371 exams are MTWTh at 6pm

% Read the announcement carefully

%

% PRS Ch > 56 <

% Concept: Strings

%

% What are they

% simple, obvious statements

% ... but necessary

% manipulating strings

% casting

% useful functions:

% strtok

% str2num

% num2str

% never submit files containing calls to:

% input

% fprintf

Review

Stirngs **********

clear

clc

str = 'abcd''ABCD' % Note the ‘ needed another ‘; 1X9 array

ascii = double(str); % cast to double, don’t think as string

next = str + 1 % What? Because 1 is a number

next = char(str + 1); % want next character not numbers

strr = '1234' % ASCII chars

num = str2num(strr) % now double

num1 = 8976.5

str1 = num2str(num1)

% capitalize all these words

str = 'now, is... the time for all good...'

% find the spaces

spaces = (str == ' ')

where = find(spaces)

firstLetts = [1 (where+1)];

str(firstLetts) = str(firstLetts) + 'A' - 'a'

[token1 rest] = strtok(str, ' ,.;?')

[token2 rest] = strtok(rest, ' ,.;?')

[token3 rest] = strtok(rest, ' ,.;?')

str = '123.4'

num = str2num(str)

num = num + 3000

nstr = num2str(num)

Array

*****Example******

clc

close all

car = imread('gray_car.jpg');

% car1 = car

imshow(car)

%car(size)

wtlc = 77;

wtlr = 80;

wbrc = 101;

wbrr = 109;

ptlc = 144;

ptlr = 95;

pbrc = 192;

pbrr = 145;

% make the wheel black

% car(wtlr:wbrr, wtlc:wbrc) = 0;

% car(ptlr:pbrr, ptlc:pbrc) = 255;

patch = car(wtlr:wbrr, wtlc:wbrc);

[prows, pcols] = size(patch);

bprows = pbrr - ptlr + 1;

bpcols = pbrc - ptlc + 1;

rindex = round(linspace(1, prows, bprows));

cindex = round(linspace(1, pcols, bpcols));

bigPic = patch(rindex, cindex);

car(ptlr:pbrr, ptlc:pbrc) = bigPic;

figure

imshow(car)