You are on page 1of 3

IT131-8L Machine Problem Answer Sheet

Machine
10 (String Manipulation and Data Structures) Score
Problem #
Name Alonzo, Isaiah Benjamin B. Section A11

1. Command Window Results:


estring = 'Lo and behold altruistic netizens, Victory is constantly ours!';
m = crypt(estring)

m=

'LabanVico'

crypt.m
function final = crypt(s)
x = length(s);
i = 1;
c = 1;
sn = [];
while i <= x
chk = s(i) == 32;
if i >= 2
chk1 = s(i-1) == 32;
end
if i == 1 && chk == 0
sn(c) = s(i);
c = c+1;
i = i+1;
elseif i == 1 && chk == 1
i = i+1;
elseif chk == 0 && chk1 == 0
i = i+1;
elseif chk == 0 && chk1 == 1
sn(c) = s(i);
c = c+1;
i = i+1;
elseif chk == 1 && chk1 == 0
i = i+1;
elseif chk == 1 && chk1 == 1
i = i+1;
else
i = i+1;
end
end
final = strtrim(strcat(sn(1,:)));

2. Command Window Results:

Prepared by: Geldof Resuello


Prepared date: March 2020
royalscramble('Isaiah Benjamin')

ans =

'sniaanjm aiBheI'

royalscramble('Alonzo')

ans =

'noozlA'

royalscramble.m
function royalscramble(s)
x = length(s);
i = 1;
sn = [];
r = randperm(x);
while i <= x
sn(i) = s(r(i));
i = i+1;
end
ans = strtrim(strcat(sn(1,:)))

3. Command Window Results:


experiments

experiments =

1×2 struct array with fields:

num
code
weights
height

experiments(1)

ans =

Prepared by: Geldof Resuello


Prepared date: March 2020
struct with fields:

num: 33
code: 'x'
weights: [200.3400 202.4500]
height: [1×1 struct]

experiments(2).weight
Reference to non-existent field 'weight'.

Did you mean:


experiments(2).weights

ans =

111.4500 111.1100

experiments initialization
experiments(1) = struct('num', 33, 'code', 'x','weights',[200.34
202.45],'height', struct('feet',5,'inches',6));
experiments(2) = struct('num', 11, 'code', 't','weights',[111.45
111.11],'height', struct('feet',7,'inches',2));

Prepared by: Geldof Resuello


Prepared date: March 2020

You might also like