Menu

[Solved]Engg1811 Virtual Lab 2 Matlab Problem 2 Functions Object Mass M Kg Suspended End Rigid Hor Q37183321

ENGG1811  Virtual Lab 2: Matlab

Problem 2: Functions

An object of mass m (in kg) is suspended from the end of a rigidhorizontal beam of length b (in metres) that is attached to a wallby a pivot. The beam is supported by a cable of the same length asthe beam attached to the beam at a distance d (in metres) from thewall. The tension T (in Newtons) on this cable is given by theequation

d237a42b-33b2-4912-8e6d-4a1e1881ce59.png

where g is the acceleration due to gravity and you can assumeits value is 9.81.

Your task is to write a function that calculates the tensiongiven the mass m, and lengths b and d as parameters. The definitionline of your function must be:

function T = calc_tension(m,b,d)

where m, b, d and T have the meaning defined earlier. Thisfunction line also appears in the Your Function box below where youwill enter your solution; note that this line has been locked soyou are not allowed to altered it. In general, lines with a greybackground in the Your Function box are locked.

Your function should work under all the following three cases onthe inputs:

  1. All the inputs are scalar.
  2. All the inputs are vectors of the same size; and,
  3. The inputs are a mixture of scalars and vectors. Note that ifmultiple inputs are vectors, then these vectors are of the samesize.

Note that we will only be using valid inputs for testing, thatmeans all values of m, b, and d are positive, and if vectors areused then they always have the same size.

Your function must not use any loops.

Under the “Code to test your function” box, there are two testswhich corresponds Cases 1 and 2 on the inputs mentioned above. Someinformation on these tests are:

  1. In this test, the parameters m, b and d are scalars. Theirvalues are respectively 100kg, 2m and 1.2m. The answer should beabout 2044N.
  2. In this test, m, b and d are the vectors [100, 200, 300], [2,3, 4], [1, 2, 3] respectively. Approximate values are [2266, 3948,5933].

Your Function C Reset MATLAB Documentation 1 function T-calc_tension (m, b,d) g- 9.81; % acceleration due to gravity % Please

Code to call your function C Reset 1%Test1: m, b, d are scalars 2% Problem parameters 3 m-1-100; % Mass of the weight 4 b-1-2

Previous Assessment: 2 of 5 Tests Passed Submit All inputs are scalars 3 All inputs are row vectors Variable T must be of siz

We were unable to transcribe this imageYour Function C Reset MATLAB Documentation 1 function T-calc_tension (m, b,d) g- 9.81; % acceleration due to gravity % Please put your solution below 6 8 end Code to call your function C Reset 1%Test1: m, b, d are scalars 2% Problem parameters 3 m-1-100; % Mass of the weight 4 b-1-2. % Length of the pole and the cable 5 d-1-1.2; % Distance from wall to cable-pole junction 6 T1-calc_tension (m_1,b_1,d_1); 9 disp(‘Your answer for test 1 is ,num2str(T 1)]) 10 disp(‘The answer should be around 2044 128% Part 2: m, b, d are vectors 13 m_2[100, 200, 3001 14 b_2[2, 3, 4]; 5 d 2 -11, 2, 3]; 16 17 T2 -calc_tension(m2,b2,d2) 18 19 disp(I’Your answer for test 1 is ,num2str(T 2)) 20 disp(‘The answer should be around (2266, 3948, 5933]’ Previous Assessment: 2 of 5 Tests Passed Submit All inputs are scalars 3 All inputs are row vectors Variable T must be of size [1 5]. It is currently of size [1 1]. Check where the variable is assigned a value. Check if you have typed the formula correctly. Remember to use brackets to follow BODMAS. Are you using elementwise or matrix operators? All inputs are column vectors Variable T must be of size [7 1]. It is currently of size [7 7. Check where the variable is assigned a value. Check if you have typed the formula correctly. Remember to use brackets to follow BODMAS. Are you using elementwise or matrix operators? Inputs are a combination of scalars and vectors Variable T must be of size [1 4]. It is currently of size [1 1]. Check where the variable is assigned a value Check if you have typed the formula correctly. Remember to use brackets to follow BODMAS. Are you using elementwise or matrix operators? Checking if loops are NOT used Show transcribed image text
Your Function C Reset MATLAB Documentation 1 function T-calc_tension (m, b,d) g- 9.81; % acceleration due to gravity % Please put your solution below 6 8 end
Code to call your function C Reset 1%Test1: m, b, d are scalars 2% Problem parameters 3 m-1-100; % Mass of the weight 4 b-1-2. % Length of the pole and the cable 5 d-1-1.2; % Distance from wall to cable-pole junction 6 T1-calc_tension (m_1,b_1,d_1); 9 disp(‘Your answer for test 1 is ,num2str(T 1)]) 10 disp(‘The answer should be around 2044 128% Part 2: m, b, d are vectors 13 m_2[100, 200, 3001 14 b_2[2, 3, 4]; 5 d 2 -11, 2, 3]; 16 17 T2 -calc_tension(m2,b2,d2) 18 19 disp(I’Your answer for test 1 is ,num2str(T 2)) 20 disp(‘The answer should be around (2266, 3948, 5933]’
Previous Assessment: 2 of 5 Tests Passed Submit All inputs are scalars 3 All inputs are row vectors Variable T must be of size [1 5]. It is currently of size [1 1]. Check where the variable is assigned a value. Check if you have typed the formula correctly. Remember to use brackets to follow BODMAS. Are you using elementwise or matrix operators? All inputs are column vectors Variable T must be of size [7 1]. It is currently of size [7 7. Check where the variable is assigned a value. Check if you have typed the formula correctly. Remember to use brackets to follow BODMAS. Are you using elementwise or matrix operators? Inputs are a combination of scalars and vectors Variable T must be of size [1 4]. It is currently of size [1 1]. Check where the variable is assigned a value Check if you have typed the formula correctly. Remember to use brackets to follow BODMAS. Are you using elementwise or matrix operators? Checking if loops are NOT used

Expert Answer


Answer to ENGG1811 Virtual Lab 2: Matlab Problem 2: Functions An object of mass m (in kg) is suspended from the end of a rigid hor… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *