You are on page 1of 3

Matlab Report sheet 6 probs(12 : 16)

12
function b=kwad(r)
y=length(r);
for x=1:y
b(x)=r(x)*r(x);
end
end

13
function B=kwadm(A)
y=size(A);
for x=1:y(1)
for z=1:y(2)
B(x,z)=A(x,z)*A(x,z);
end
end
end

14
function b = replace(a)
y=length(a);
b=a;
for x=1:y
if b(x)>5
b(x)=0;
end
end
end
15
function B = replace2(A)
y=size(A);
B=A;
for x=1:y(1)
for z=1:y(2)
if B(x,z)>5
B(x,z)=0;
end
end
end
end

16
function [p,q] = divide(x)
q=x;
p=0;
while q>=2
q=q/2;
p=p+1;
end
end

You might also like