Sunteți pe pagina 1din 2

MATLAB Programming for Numerical Computations

JanMarch 2017

Assignment for Module1


Due on: This assignment does not have a due date
INSTRUCTIONS

Submit your work on the course website ( https://onlinecourses.nptel.ac.in/noc16_ch01/ )

Please visit the help section of the course webpage to know exactly how to submit

Please follow all the instructions carefully

This assignment is not graded. It is intended to get acquainted with submission portal.

1. DEMO PROBLEM
For in the range x=[0:0.1:1], calculate = %&' . Report the value of at
which is maximum.
1.

Report the value of for which the above function value is the highest

2. VECTOR SUMMATION
Given a vector x, calculate the following:
oddSum = 1 + 3 + 5 +
funVal = 1 2 + 3 4 +
Your should create a function vectorSum that takes one input vector x, and returns two
scalars, oddSum and funVal. Also update these results on the module assessment page for:
x=[0.81

0.91

x=[4

25.

0.12

0.91

0.63

0.09

0.28].

3].

Report the value of oddSum and funVal for the two vectors x given above

3. SALARY PROBLEM
Two friends A and B start with initial salaries of 1 unit and 1.25 unit, respectively. At the
end of each year, they get a raise of 6% and 2% respectively. Write a MATLAB code that uses
either a for or while loop to calculate annual salaries of the two until the year when As
salary exceeds that of Bs. Report the value of the earliest year when As salary exceeds Bs.
When the program ends, A and B should be a -dimensional vectors, containing their
salaries in the respective years.
6.

Report the value of n for which the salary of A first exceeds that of B.

MATLAB Programming for Numerical Computations

JanMarch 2017

4. PLOTTING
Define vector t=[0:0.04:4];. Define vertical location of the ball using equation
= 4 0.5 & , as was done in video lectures on Loops and Execution Control. The
values to use are 9 = 20 and = 9.8. Both t and y are 101-dimensional vectors.
We now wish to do the same plot in a different way. The command plot(t,y,'-bo')
gives blue line with data-points shown as open circles. Since the data is closely spaced, this
plot looks cluttered.
Instead, plot the same graph such that the blue line is as before, but the circles are shown
only at 0.4 seconds interval (i.e., line goes through all 101 points, but symbols are shown for
11 points only). The plot should look like the one below:

Hint: You will have to plot the same data twice: using '-b' to plot the line, and using 'bo'
to plot the symbols only.
If you repeat the problem for t=[0:0.04:3]; keeping everything else the same, how
many symbols are plotted on the figure? Please enter this value in assessment page
7.

Report the number of symbols on the plot, when t=[0:0.04:3];

S-ar putea să vă placă și