Professional Documents
Culture Documents
1.)
function A = make_A(a,b,c,d)
A=zeros(2,2);
A(1,1) = a;
A(1,2) = b;
A(2,1) = c;
A(2,2) = d;
2.)
function y = funplots(x)
y = sin(x); % Find sin(x)
[x,y]
% Print table to the screen
% x was supposed to be a column..
plot(x,y,'r--') % Plot your answer
xlabel('x')
ylabel('sin(x)')
3.)
function y = funky(x)
y = sqrt((x-2).^2)/pi.*sin(pi*x); % Computations
[x,y]
4.)
% Create an 8x8 matrix of my choice
A = [1 2 3 4 5 6 7 8;
2 4 6 8 10 12 14 16;
3 6 9 12 15 18 21 24;
4 8 12 16 20 24 28 32;
5 10 15 20 25 30 35 40;
6 12 18 24 30 36 42 48;
7 14 21 28 35 42 49 54;
8 16 24 32 40 48 56 64];
%
y
z
x
5.) Make the above file into a function m-file with A as the input.
for i=1:n
sum = sum + x(i); % add up all the components of x
end
a = sum/n; % find the average
2.)
function s = std_dev(x)
n = length(x); % Find the length of x
a = ave(x);
% find the average
sum = 0;
% Initialize sum
for i=1:n
sum = (x(i)-a)^2;
end
s = (1/(n-1))*sum;