Matlab Programming Help

Discussion in 'Programmer's Corner' started by elec_lolo, Nov 25, 2008.

  1. elec_lolo

    Thread Starter New Member

    Nov 24, 2008
    4
    0


    hi friends ...how is all? any one can help me to find a solution for any part of this homework ...plz send me i need that ??my doctor need the solution next day and thx alot?



    Name & ID: ........................................................I..c..e..r.t.ify that I did not receive any illegal aid in doing this homework
    EE100 Homework # 6 Due Tuesday 2008.11.25​
    The homework has 7 questions.​
    Solve questions 1, 2 and 2 and submit your printed program and printed results​
    .
    The rest of the questions needs preparation at home by reading several pages from the textbook and will be discussed
    in the lab.
    1. Use Pspice to solve drill problem 2.11a in HK5e page 99 to find the current
    i10 in the circuit.
    2. (Chapman 5.9) Write three MatLab functions to calculate the hyperbolic sine
    sinh(x) = e

    x​
    −​
    e

    −​
    x

    2 ​
    , cosine cosh(x) =

    e​
    x​
    +e

    −​
    1

    2 ​
    , and tangent tanh(x) = e

    x​
    −​
    e

    −​
    x

    e​
    x​
    +ex functions. Write a calling program to test the three functions for the
    values x=0, 1, and 10. Use your functions to plot the shapes of the hyperbolic sine, cosine, and tangent functions.
    3. (Chapman 5.11) Sort with Carry. It is often useful to sort an array arr1 into ascending order, while simultaneously
    carrying along a second array arr2. In such a sort, each time an element of array arr1 is exchanged with another
    element of arr1, the corresponding elements of array arr2 are also swapped. When the sort is over, the elements of
    array arr1 are in ascending order, whereas the elements of array arr2 that were associated with particular elements
    of array arr1 are still associated with them. For example, suppose we have the following two arrays.
    Element
    arr1 arr2
    1 6 1
    2 1 0
    3 2 10
    After sorting array arr1 while carrying along array arr2, the contents of the two arrays will be
    Element
    arr1 arr2
    1 1 0
    2 2 10
    3 6 1
    Write a function to sort one real array into ascending order while carrying along a second one. Test the function
    with the following two 9-element arrays.

    a ​
    1 11 6 17 23 0 5 1 1

    b ​
    31 101 36 17 0 10 8 1 1
    Test your results by applying the MatLab function ’sortrows’ on your data.
    Page 1 of 2

    Please go on to the next page. . .​
    EE100 Homework # 6 Due Tuesday 2008.11.25​
    • ​
    Reference Kuncicky pages 111-123 on polynomial: evaluation (polyval), add/subtract, multiply (conv), divide
    (deconv), derivative (polyder), and roots (roots).

    • ​
    Reference Kuncicky pages 91-100 on matrices: zeros, ones, array plotting (plot, semilogx, semilogy, loglog,
    multiple plot of polynomial curves, multiple plot of polynomial curves with separate y axes) and the commands
    axis, hold, grid, xlabel, ylabel, title, figure(n), close (figure), close(all), clf, and subplot(m,n,p) (m by n grid
    of windows and p the current window).
    4.
    x = rand returns a number between 0 and 1 drawn from a uniform distribution.

    y ​
    = 1 + 2  rand returns a number between 0 and 1.
    In general
    y = a + (b a)  rand returns a number between a and b.
    Flipping a coin (Kuncicky page 149): if Head=1, Tail=0 then
    coin = floor(2  rand) will return 0 or 1.
    toss=[]; for k=1:1:1000, toss=[toss; floor(2*rand)]; end
    will return 1000 integers each having the value 0 or 1 (Tail or Head). If the function
    rand generates uniformly
    distributed random numbers between 0 and 1 [0,1), then the average of the vector
    toss should be around 0.5 and
    its variance should be
    1
    4
    and the standard deviation =pV ariance = 1
    2
    . Verify the values for the mean, variance
    and standard deviation using the MatLab functions
    mean(toss), var(toss), and std(toss).
    5. (Chapman 5.6) Write a function that uses function
    rand to generate a random value in the range [low, high),
    where low and high are passed as calling arguments. Write a program to test your function by generating 10000
    numbers for low=-2, high=17 and follow the procedure as in the previous question for the mean, variance, and
    standard deviation.

     
  2. elec_lolo

    Thread Starter New Member

    Nov 24, 2008
    4
    0
    7. (Chapman 4.16) MatLab Least-Squares Fit Function. MatLab includes a standard function that performs a least-
    squares fit to a polynomial. Function polyfit calculates the least-squares fit of a data set to a polynomial of order
    N.​
    p​
    (x) = anxn + an1xn1 + · · · + a1x + a0

    where N can be any value greater than or equal to 1. Note that for N = 1, this polynomial is a linear equation,
    with the slope being the coefficient ​
    a1 and the y-intercept being the coefficient a0. The form of this function is

    p ​
    = polyfit(x, y, n)
    where
    x and y are real vectors, and n is the order of the fit.
    Write a program that calculates the least-squares fit of a data set to a straight line using polyfit. Plot the input
    data points and the resulting fitted line. Test your program on the following set of (
    x, y) data points.
    (1.1, 1.01), (2.2, 2.30), (3.3, 3.05), (4.4, 4.28), (5.5, 5.75), (6.6, 6.48), (7.7, 7.84).

    Do not forget to write your name and ID then sign next to your name at the top of page 1​
    Page 2 of 2​
    End of Homework​
     
  3. elec_lolo

    Thread Starter New Member

    Nov 24, 2008
    4
    0
    and thx 4 all
     
  4. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    145
    Please do not hijack another members thread.

    What have you done on this homework? Are you expecting someone just to spoon-feed you the answer?

    Dave
     
  5. blazedaces

    Active Member

    Jul 24, 2008
    130
    0
    ...

    Please re-read the above statement...

    -blazed
     
  6. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    145
    I must say, that bit raised a smile!

    Dave
     
  7. elec_lolo

    Thread Starter New Member

    Nov 24, 2008
    4
    0
    ohh...thx 4 help .....
     
Loading...