Q1. Create the matrices A and B: [ ] [ ] and find a) b) c) SOLUTION: A=[3 -2 1 ;-1 5 4] B=[7 3 -1; 2 4 1] a) 2*A-B = [-1 -7 3 ; -4 6 7] b) A.^2 + 3 = [ 9 4 1 ; 1 25 16] + 3 = [12 7 4 ; 4 28 19] c) A.*B – 2 = [21 -6 -1; -2 20 4 ] – 2 = [ 19 -8 -3; -4 18 2] Q2. The mechanical work (W) done in using a force (F) to push a block through a distance (D) is W = FD. The following table gives data on the amount of force used to push a block through the given distance over five segments of a certain path. Use MATLAB to find the work done on each segment of the path. 1 400 3 Force (N) Distance (m) Path segment 2 3 4 550 700 500 0.5 0.75 1.5 SOLUTION: Force = [400 550 700 500 600] Distance=[3 0.5 0.75 1.5 5]; Work=F.*Distance [ 1200 275 525 750 3000] Q3. Create the matrix X: [ and find a) a = size(X) b) e = size(X,1) c) f = size(X,2) ] 5 600 5 d) [j,k] = max(X) e) min(X) SOLUTION: X=[3 7 -4 12; -5 9 10 2; 6 13 8 11; 15 5 4 1] a) 4 4 b) 4 c) 4 d) j = 15 13 k = 4 3 e) -5 5 10 12 2 1 -4 1 Q4. Given the following matrix, a, find and show in matrix form the resulting matrices in each case: 1 2 a 3 4 1 0 2 1 1 0 3 3 3 0 0 4 a) Find the resulting arrays b, c and d provided that the assignment statements are given b=a(1:3, 2:end); c=[a(4,1:3); ones(1,3)*-1] b) Create a 4X4 matrix out of the components shown below. Initially find matrix e then construct matrix A. e = a(3:-2:1,3:end) A = [e, 2*e ; e.^2, e + 2 ] SOLUTION: a) b= 1 0 1 -1 3 3 c= 2 0 3 4 0 0 -1 -1 -1 b) e= A= 3 0 3 2 3 0 9 0 3 2 9 4 6 0 5 2 6 4 5 4 Q5. The volume V of a cylinder of radius r and height h is given by Write a script to compute the volume of the cylinder of given radius m and height h = 5 m. Create a radius array containing values in the given range with 0.5 m increment. Then, calculate and print out the radius and the corresponding volumes in two columns on the screen. SOLUTION: %This script calculates the volume of cylinder for a given %radius and height h=5; r=0:0.5:5; V= pi*r.^2*h; table= [r',V'] OR table=[r;V]'
© Copyright 2026 Paperzz