tutorial 5- matlab programming

Upload: darksky-paul

Post on 18-Oct-2015

57 views

Category:

Documents


0 download

TRANSCRIPT

  • Engineering Software & Applications

    Tutorials

    Chapter 5 - MATLAB Programming

    1. Consider the array A.

    3 5 48 1 33

    17 6 9A

    =

    Write a MATLAB script that computes the array B by computing the natural logarithm of all the

    elements of A whose values is no less than 1, and adding 20 to each element that is less than 1.

    Using a for loop with conditional statements.

    2. Electrical resistors are said to be connected in series if the same current passes through each

    case and in parallel if the same voltage is applied across each.

    If in series, they are equivalent to a single resistor whose resistance is given by:

    1 2 3 ... nR R R R R= + + + +

    If in parallel, their equivalent resistance is given by:

    1 2 3

    1 1 1 1 1...

    nR R R R R

    = + + + +

    Write a MATLAB script that prompts the user for the type of connection (series or parallel)

    and the number of resistors n and then computes the equivalent resistance.

    3. Use a while loop to determine how many terms in the series 2k, k = 1, 2, 3, ., are required for

    the sum of the terms to exceed 2000. What is the sum for this number of terms?

    4. The following table gives the approximate values of the static coefficient of friction for various materials:

    Materials Metal on metal 0.2

    Wood on wood 0.35

    Metal on wood 0.40

    Rubber on concrete 0.70

    To start a weight W moving on a horizontal surface, you must push with a force F, where F=W. Write a MATLAB Programme that uses the switch structure to compute the force F. The

    programme should accept as input the value of W and the type of materials.