Script File Code The distance d is 2. 2. Repeat Problem 1 by - - PDF document

script file code the distance d is 2 2 repeat problem 1
SMART_READER_LITE
LIVE PREVIEW

Script File Code The distance d is 2. 2. Repeat Problem 1 by - - PDF document

UNIVERSITY OF JORDAN UNIVERSITY OF JORDAN COMP CO MPUTER ENGI UTER ENGINEERIN NEERING DEPARTM G DEPARTMENT NT CPE0907311 COMPUTER APPLICATIONS LAB CPE0907311 COMPUTER APPLICATIONS LAB EXERC EXERCISE SHEET 4 SE SHEET 4 STUD STUDY THE


slide-1
SLIDE 1

CPE0907311 COMPUTER CPE0907311 COMPUTER APPLICATIONS LAB APPLICATIONS LAB EXERC EXERCISE SHEET 4 SE SHEET 4

1 1

UNIVERSITY OF JORDAN UNIVERSITY OF JORDAN CO COMP MPUTER ENGI UTER ENGINEERIN NEERING DEPARTM G DEPARTMENT NT

Prepared by Dr. Iyad Jafar

STUD STUDY THE S Y THE SLIDES O IDES OF EXPERI EXPERIMENT 4 MENT 4 AND SOLV AND SOLVE THE FO E THE FOLLOW LLOWING ING PROB PROBLEMS LEMS BEFORE COMING TO THE LAB. BEFORE COMING TO THE LAB.

1.

  • 1. The capacitance of two parallel conductors of length L and radius r, separated by a distance d

is given by

L C = d r ln r πε − ⎛ ⎞ ⎜ ⎟ ⎝ ⎠

where ε is the permittivity of air (ε =8.854x10-12 F/m). Write a script file that accepts user input for C, L, and r, and computes and displays the distance value d that gives in the specified capacitance value C. Test your file with L = 0.5 m, r = 0.01 m, and C = 1 µF. Script File Code The distance d is

2.

  • 2. Repeat Problem 1 by writing a Matlab function that accepts the input values C, r, and L in its

argument and returns calculated value d. Your function should be written such that it is capable of processing single and multiple values for C, r, and L, i.e. it should operate on

  • vectors. Test your function with the following values C = [2 mF , 0.1 mF], L = [0.2 m 0.1m],

and r = [0.05 and 0.02]. Function Code

slide-2
SLIDE 2

CPE0907311 COMPUTER CPE0907311 COMPUTER APPLICATIONS LAB APPLICATIONS LAB EXERC EXERCISE SHEET 4 SE SHEET 4

2 2

UNIVERSITY OF JORDAN UNIVERSITY OF JORDAN CO COMP MPUTER ENGI UTER ENGINEERIN NEERING DEPARTM G DEPARTMENT NT

Prepared by Dr. Iyad Jafar

Distance

3.

  • 3. Use a text editor to create a file containing the data given below. Write a Matlab function that

accepts the name of the file as a string and returns the content of the file and the minimum and maximum values of each row in three output arguments: data,minValue, and maxValue. Code

4.

  • 4. Enter and save the data given in problem 4 in a spreadsheet. Write a script file to import the

data to a MATLAB variable M then displays the sum of elements of the loaded data on the command prompt. Script File Code 23 , -91, 73, 2 33, 14, 5.43, 3 15, 2, 32,

  • 21
  • 9,

3.3, 1, 11

slide-3
SLIDE 3

CPE0907311 COMPUTER CPE0907311 COMPUTER APPLICATIONS LAB APPLICATIONS LAB EXERC EXERCISE SHEET 4 SE SHEET 4

3 3

UNIVERSITY OF JORDAN UNIVERSITY OF JORDAN CO COMP MPUTER ENGI UTER ENGINEERIN NEERING DEPARTM G DEPARTMENT NT

Answer

5.

  • 5. Write a function to find the coefficients of the polynomial y = ax3 + bx2 + cx + d. The

functions should accept a set of four data points (xi,yi), i=1,2,3,4 and solve four linear equations in terms of the four unknowns a,b,c, and d. Test your function for the case where (xi,yi)= (-2,-20), (0,4), (2,68), and (4,508), whose answer is a = 7, b=5, c = -6, and d = 4.

6.

  • 6. A company wants to locate a distribution center that will serve six of its major customers in a

30x30 mi area. The locations of the customers relative to the southwest corner of the area are given in the following table in terms of (x,y) coordinates (the x direction is east; the y direction is north) (see figure below). Also given is the volume in tons per week that must be delivered from the distribution center each customer. The weekly delivery cost ci for customer i depends on the volume Vi and distance di from the distribution center. For simplicity we will assume that the distance is a straight line distance. The weekly cost ci = 0.5 Vi * di ; i = 1,2,…,6. Formulate the total cost function for all customers then use MATLAB to find the

  • ptimal location for the distribution center (the location that produces the minimum total

weekly cost). Hint: formulate the objective function as a function handle and then use the fminsearch function. Customer x Location (miles y Location (miles) Volume (tons/week) 1 1 28 3 2 7 18 7 3 8 16 4 4 17 2 5 5 22 10 2 6 27 8 6

5 10 15 20 25 30 5 10 15 20 25 30

x (miles) y (miles)

1 2 3 4 5 6

Prepared by Dr. Iyad Jafar