% Solutions for problem set 1, EN 74, Fall 2007 % CREATING VARIABLES % Problem 1 a = 1 b = -2 c = -5.5 d = 7 % Problem 2 s = a+b+c+d p = a*b*c*d % Problem 3 clear a b c whos % PERFORMING CALCULATIONS % Problem 4 sc = -1.3 vct = [1;2;3] mtx1 = [1 2 3 ; 4 5 6 ; 7 8 9] mtx2 = [1 2 3 ; 1 2 3; 1 2 3] % Problem 5 sc*vct % Problem 6 mtx1*vct % Problem 7 mtx1*mtx2 % Problem 8 mtx1.*mtx2 % Problem 9 mtx1(:,1).^vct % Problem 10 time = -1:.01:1 lt = length(time) % We have 201 points in time since we include both "ends" i.e., 1 and -1 in % the vector % Problem 11 t = linspace(-1,3,2000); y = sin(10*t) .* cos(20*t).^2 .* exp(-9*t/10); plot(t,y);xlabel('time');ylabel('y(t)') % Problem 12 x = linspace(-1,1,50); y = x; [X Y] = meshgrid(x,y); f = X.^2 .* (1-Y).^3 .* (1+abs(X)).^(-1); mesh(x,y,f) xlabel('x');ylabel('y');zlabel('f') % Problem 13 imagesc(x,y,f) xlabel('x');ylabel('y');zlabel('f') % Problem 14 % This is the script