School Work

Eng1060 Lab 2

computing for engineers
of 3
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Related Documents
   ENG1060 – Computing for Engineers Laboratory No.2 (Week 3) Page 1 of 3 This laboratory comprises 2% of your final grade. You will be assessed during your laboratory session by the demonstrators. You will be assessed on the quality of your programming style as well as the results produced by your programs. Save your work in M-Files  called lab2t1.m  , lab2t2.m   etc. The questions are designed to test your recollection of the lecture material in week 1 and 2. This laboratory will introduce you to MATLAB and cover variables, matrices and plotting. Note:  Some of the functions presented would be new to you and you should use the MATLAB HELP   to learn it how to use them. Task 1 – 1 mark Using MATLAB, write an M-file that does the following: (i) Creates a vector t   ranging from 1 to 10 in steps of 0.5 (ii) Creates a vector theta   that contains 19 elements ranging from 0 to π . (iii) Computes the following: )sin(2  θ   =  x   4)(sin 2  t  y  ×=  θ     Hint : You might use the MATLAB inbuilt function ‘linspace’ Faculty of Engineering Semester 1 - 2014 ENG1060 Computing for Engineers Laboratory No. 2     ENG1060 – Computing for Engineers Laboratory No.2 (Week 3) Page 2 of 3 Task 2 – 2 marks  All points with coordinates x   = rcos( θ ) and y   = rsin( θ ), lies on a circle with radius r  . Write a MATLAB code that creates a vector for θ  with 9 values from 0 to 2 π  and uses r = 2 to plot the coordinates of x   vs y   (using a red line) to check if a circle with radius 2 is actually obtained (if not, what would you change in the code to fix the problem). Note : Ensure your plot is labelled Task 3 – 2 marks  Using MATLAB and these two matrices 1 4 2 A = 2 4 100 B = ln(A) 7 9 7 3 6 10 a) Select just the second row of B b) Evaluate the sum of the second row of B c) Find the element-by-element square of matrix A d) Form a 2X2 sub-matrix from A comprising of all the elements in the 2 nd  & 3 rd  row and 1 st  & 3 rd  column e) Evaluate the sum of the first row of A and divide it element-by-element by the first three elements of the third column of B Task 4 – 2 marks When asked to provide a trigonometric solution, such as sine or cosine , MATLAB uses a Taylor series as an approximate solution. For example, the series solution for sin(x) and cos (x) are: ( ) ( )( ) 120 !121sin  +∞= +−Σ=  nnn  xn x  ; ( ) ( )( ) nnn  xn x 20 !21cos  −Σ= ∞=     ENG1060 – Computing for Engineers Laboratory No.2 (Week 3) Page 3 of 3 Prior to the advent of modern computing, this series solution was used to provide accurate estimates of sin(x) and cos(x). Now, computer programs use the same technique to estimate sine. a) Write an M-file  which will calculate sin( π  /5) using from one to six terms (for n up to 0, n up to 1 … n up to 5) in the series solution. For each of the six cases, compare the answer from the series solution to the answer given from the MATLAB built-in function “sin(x)” as a percentage error . b) Write an M-file  program which calculates tan(x). Note:   Use the trigonometric identity )cos()sin()tan(  x x x  =   The program should use the first six terms (n up to 5). Calculate the Taylor tan approximation values of x going from –  π 󰁴󰁯 π 󰁩󰁮 󰀰󰀮󰀱 󰁩󰁮󰁣󰁲󰁥󰁭󰁥󰁮󰁴󰁳 󰀮 󰁐󰁬󰁯󰁴 󰁴󰁨󰁥 󰁡󰁢󰁳󰁯󰁬󰁵󰁴󰁥 󰁥󰁲󰁲󰁯󰁲  󰁢󰁥󰁴󰁷󰁥󰁥󰁮 󰁹󰁯󰁵󰁲 󰁔󰁡󰁹󰁬󰁯󰁲 󰁴󰁡󰁮󰀨󰁸󰀩 󰁡󰁰󰁰󰁲󰁯󰁸󰁩󰁭󰁡󰁴󰁩󰁯󰁮 󰁡󰁮󰁤 󰁍󰁁󰁔󰁌󰁁󰁂󲀙󰁳 󰁢󰁵󰁩󰁬󰁴󰀭󰁩󰁮 󰁴󰁡󰁮 󰁦󰁵󰁮󰁣󰁴󰁩󰁯󰁮󰀮 󰁎󰁯󰁴󰁥󰀺   trueapproxerror  Absolute  −= _  Task 5 – 3 marks A simply supported beam that is subjected to a constant distributed load w   over two-thirds of its length is shown below. The deflection y, as a function of x, is given by the equations:      +−−= 4223 816491624  L x L Lx  LEI wx y  for 0 ≤   x    ≤    L 32        −+−−= 3223 949406254  L x L Lx x  EI wL y  for  L 32   ≤   x    ≤    L  Where E   is the elastic modulus, I   is the moment of inertia and L  is the length of the beam. For the case where L  = 20m, E   = 200 x 10 9 Pa, I   = 348 x 10 -6  m 4 , and w   = 5 x 10 3  N/m, write a MATLAB code that plots the deflection of a beam ( y  ) as a function of the beam length ( x  ) and use matrix addressing to find the maximum deflection of the beam and where along the beam does it occur.


Jul 23, 2017
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks