Write a user-defined matlab function that calculates a


Assignment

Use MATLAB to solve each problem by writing script files; copy and paste the script file AND the results in the Command Windowand/or plot in the Figure Windowto a WORD document that has your name and section in the headers of each page and the page number in each footer. Edit the output to remove extra lines and empty spaces. The script files SHOULD have comments for easy readability; take a print out of the Word file andstaple before submission.

1. Plot the function y = 10(1-e-x/4) over the interval 0 £ x £xmax, using a while loop to determine the value of xmax such that y(xmax) = 9.8. The variable y represents force in Newtons, and the variable x represents time in seconds. Include title, grid, and axis labels.

2. A weight is supported by two cables anchored a distance D apart as shown.

746_A Weight.jpg

The cable length LAB is given, but the length LAC is to be selected. Each cable can support a maximum tension force equal to W. For the weight to remain stationary, the total horizontal force and the total vertical force must each be zero. This principle gives the equations

          -TAB cosq + TAC cos f = 0
           TAB sinq + TAC sin f = W

W can solve these equations for the tension forces TAB and TAC if we know the angles q and f. From the law of cosines

                                            θ = cos-1 [(D2 + L3AB - L2AC) / 2DLAB]
From the law of sines              Φ = sin-1 (LAB sinθ / LAC)

For the given values D = 6 feet, LAB = 3 feet, and W = 2000 pounds, use a loop in MATLAB to find LACmin, the shortest length LAC we can use without TAB or TAC exceeding 2000 pounds. Note that the largest LAC can be is 6.7 feet (which corresponds to q = 90°). Plot the tension forces TAB and TAC on the same graph versus LAC for LACmin£ LAC£ 6.7.

3. An ideal diode blocks the flow of current in the direction opposite that of the diode's arrow symbol. It can be used to make a half-wave rectifier as shown.

1501_Half-Wave Rectifier.jpg

For the ideal diode, the voltage vL across the load RL is given by

               vL = vSif  vS> 0
                   = 0      if  vS£ 0

For a non- ideal (silicon) diode, the voltage vL is given by

               vL = vS-0.6    if  vS> 0.6
                   = 0      if  vS£ 0.6

Suppose the supply voltage is vs(t) = 3e-t/3 sin(pt) volts, where time t is in seconds. Write a MATLAB program to plot the voltage  vL versus t for both ideal and non-ideal cases  and the voltage vS versus t for 0 £ t £ 10 on the same axes.

4. Write a user-defined MATLAB function that calculates a student's final grade in a course using the scores from three midterm exams, a final exam, and six homework assignments. The midterms are graded on a scale from 0 to 100, and are each 15% of the final grade. The final exam is graded on a scale from 0 to 100, and is 45% of the final grade. The six homework assignments are graded each on a scale from 0 to 10. The homework assignments together are 10% of the final grade.

For the function name and arguments use g=fgrade(R). The input argument R is a matrix in which the elements in each row are the grades of one student. The first six columns are the homework grades (numbers between 0 to 10), the next three columns are the midterm grades (numbers between 0 to 100), and the last column is the final grade (a number between 0 to 100). The output from the function, g, is a column vector with the final grades for the course. Each row has the final grade of the student with the final grades in the corresponding row of the matrix R. 

The function can be used to calculate the grades of any number of students. For one student matrix R has one row. Use the function in the following cases:

a) Use the Command Window to calculate the grade of one student with the following grades:

(8, 9, 6, 10, 9, 8, 76, 86, 91, 80).

b) Write a program in a script file. The program asks the user to enter the student's grades in an array (each student a row). The program then calculates the final grades by using the function fgrade. Run the script file to calculate the grades of the following four students:   

Student A:  8, 10, 6, 9,10,9, 91, 71, 81, 85.
Student B:  5, 5, 6, 1, 8, 6, 59, 72, 66, 59.
Student C:  6, 8, 10, 4, 5, 9, 55, 65, 75, 78.
Student D:  7, 7, 8, 8, 9, 8, 83, 82, 81, 84.

Solution Preview :

Prepared by a verified Expert
MATLAB Programming: Write a user-defined matlab function that calculates a
Reference No:- TGS02245722

Now Priced at $55 (50% Discount)

Recommended (90%)

Rated (4.3/5)