0% found this document useful (0 votes)
108 views5 pages

Octave Exercises Eng

The document contains 27 math and programming exercises involving Octave/MATLAB. The exercises cover topics like arrays, functions, plotting, interpolation, integration, solving equations, and more.

Uploaded by

Irina Stanciu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views5 pages

Octave Exercises Eng

The document contains 27 math and programming exercises involving Octave/MATLAB. The exercises cover topics like arrays, functions, plotting, interpolation, integration, solving equations, and more.

Uploaded by

Irina Stanciu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Octave exercises:

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.

2. Use OCTAVE to determine how many elements are in the array:


sin(-pi/2):0.05:cos(0). Use OCTAVE to determine the 10th element.

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

4. Evaluate the polynomial =9 +5 − 3 − 7, at the points x = 0, 2, 4, . . . , 10,


and plot it for 0<x<10

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

4 sin sin 3 sin 5 sin 7


+ + + +⋯
1 3 5 7

Plot on the same graph the function f (x) and its series representation, using the four terms
shown.

6. A cycloid is the curve described by a point P on the circumference of a circular wheel of


radius r rolling along the x axis. The curve is described in parametric form by the

= − 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.

10. Create an anonymous function = 10) * +


and plot it over the range 0 < x < 2.

11. Write a script file to plot the function


15√4 + 10, ≥9
= ,10 + 10, 0≤ <9
10, <0

For -5 < x < 30.

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

13. Generate a three-dimensional curve, given by the equations:

= ) *'.'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

17. Approximate the function = 10) * + , on the interval [0,2], using


a. Linear interpolation with 5 points
b. Linear interpolation with 10 points
c. Cubic spline interpolation with 5 points
d. Cubic spline interpolation with 10 points
What approximation is the most precise?

18. Approximate the function = 10) * + using


a. Linear interpolation with 5 points
b. Linear interpolation with 10 points
c. Cubic spline interpolation with 5 points
d. Cubic spline interpolation with 10 points
Créer une matrice de graphique qui compare le graphique de f avec les représentations
graphiques de les quatre approximations de f.

19. Consider the following data:

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.

24. Determine the distance traveled for the following data:


a. Use the trapezoidal rule
+ 9+
b. Use the midpoint method (D ∑K?LJ E FGH FI ?9J ? )

t 1 2 3.25 4.5 6 7 8 9 9.5 10


v 5 6 5.5 7 8.5 8 6 7 7 5

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

You might also like