Documente Academic
Documente Profesional
Documente Cultură
INSTRUCTIONS
1. DEMO PROBLEM
2. VECTOR SUMMATION
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.
1
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];