Octave Exercises Eng
Octave Exercises Eng
1. Suppose x takes on the values x=1, 1.2, 1.4, . . . , 5. Use OCTAVE to compute the array y
that results from the function y = 7 sin(4x). Use OCTAVE to determine how many
elements are in the array y and the value of the third element in the array y.
5 − 2 , with k = 1, 2, 3, . . . , to exceed 10 000. What is the sum for this many terms?
3. Write a script file to determine the number of terms required for the sum of the series
5. The Fourier series is a series representation of a periodic function in terms of sines and
1, 0< <
cosines. The Fourier series representation of the function
=
−1, − < <0
is
Plot on the same graph the function f (x) and its series representation, using the four terms
shown.
= − sin
equations
= 1 − cos
Use these equations to plot the cycloid for r =10 and 0 < <4
7. The maximum height h achieved by an object thrown with a speed at an angle θ to the
$ sinθ
horizontal, neglecting drag, is
ℎ=
2&
Create a matrix showing the maximum height for the following values of θ and v:
v = 10, 12, 14, 16, 18, 20 m/s θ = 50°, 60°, 70o. The rows in the matrix should correspond
to the speed values, and the columns should correspond to the angles.
1
8. An object thrown vertically with a speed v0 reaches a height h at time t, where
ℎ = $' ( − &(
2
Write and test a function that computes the height reached after a specified time, t, for a
given value of v0. The function’s inputs should be t, v0 and g. Test your function for the
case where t= 10s, v0=50 m/s, and g = 9.81 m/s2.
1
9. An object thrown vertically with a speed v0 reaches a height h at time t, where
ℎ = $' ( − &(
2
Write and test a function that computes the height reached after a specified time, t, for a
given value of v0. The function’s inputs should be t, v0 and g. Create a matrix plot that
compares the variation of the height over the time interval [0s, 20s], for three values of
the initial velocity: v0=10 m/s, 50 m/s and 100 m/s.
12. Plot the following two data sets on the same plot. For each set, x = 0, 1, 2, 3, 4, 5. Use a
different data marker for each set. Use a legend, and label the plot axes appropriately.
The first set is y1 =11, 13, 8, 7, 5, 9. The second set is y2 = 2, 4, 5, 3, 2, 4
= ) *'.'34 sin (
1 = ) *'.'34 cos (
5=(
for t from 0 to 10.
14. Generate a 3D surface plot and mesh plot of the function , = ) *[ +*7 8 8 97 8 ]
, for -
2 < x < 2 and -2 < y <2, with a spacing of 0.1
15. The upward velocity of a rocket is given as a function of time. Find the velocity at t=16
seconds, using linear interpolation.
v(t)
t(s) (m/s)
0 0
10 220
15 360
20 510
22 600
30 900
16. The upward velocity of a rocket is measured at some points in time. Plot the data,
connecting them with cubic splines.
v(t)
t(s) (m/s)
0 0
10 220
15 360
20 510
22 600
30 900
x 0 2 4 6 9 11 12 15 17
y 5 6 7 6 9 8 7 10 12
=; +<
The linear regression curve is given by the expression:
=∑ ? −∑ ?∑
where
;=
? ?
=∑ ? − ∑ ?
1 ;
<= @ @
= ?
= ?
Plot the data points and the regression curve on the same axes, using different colors.
20. Temperatures are measured at various points on a heated plate. Estimate the temperature
at x=4.3, y=3.2. Represent a graphic with the variation of the temperature across the
plate.
21. Create a matrix plot with the graphic of a function ) + , and the graphic of
the derivative of f, for -1<x<1.
22. The following data was collected for the distance traveled versus time for a rocket:
t 0 25 50 75 100 125
d 0 20 48 82 124 180
Estimate the rocket’s velocity and acceleration at 25s, 50s, and 100s
C
23. Compute the integral A' sin B using:
a. The trapezoidal method
+FGH 9+F
b. The midpoint method (D ∑K?LJ E I ?9J ? )
c. Simpson’s rule
d. Gauss quadratures.
6 + 12 + 45 = 70
25. Solve the set of linear algebraic equations:
1 7 − 2 + 35 = 5
2 + 8 − 95 = 64
2 − 4 + 55 = −4
26. Solve the linear system:
1−4 − 2 + 35 = 4
2 + 6 − 85 = 0
+ 3 + 25 = 2
27. Find two solutions to the following set:
+ +5 =4
B
28. Use OCTAVE to compute and plot the solution of the following equation:
10 + = 20 + 7 sin 2
B
0 = 15