Professional Documents
Culture Documents
Machine
10 (String Manipulation and Data Structures) Score
Problem #
Name Alonzo, Isaiah Benjamin B. Section A11
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,:)));
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,:)))
experiments =
num
code
weights
height
experiments(1)
ans =
num: 33
code: 'x'
weights: [200.3400 202.4500]
height: [1×1 struct]
experiments(2).weight
Reference to non-existent field 'weight'.
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));