2D plotting
Problem 1
Damped oscillation equation: y=e−at cos( bt )
Where, a = 0.1, b = 1, t (initial: 0, final: 20, interval: 0.1)
Plot the y versus t graph. Label and format the plot including axis labels, and legends so that you can
clearly communicate the solution.
Problem 2
Plot the data included in the table:
a 1 2 3 4 5 6 7 8 9 10
b 1 4 5 7 8 9 2 4 5 6
c 1 2 7 5 6 4 2 3 4 7
Plot the b versus a graph overlapped with c versus a graph. Label and format the plot including axis
labels, tittle, and legends so that you can clearly communicate the solution.
3D plotting
3D Line plot:
Problem 3 (Matlab)
t (initial: 0, final: 10π, interval: π/50)
s(t) = sin(t)
c(t) = cos(t)
Make a 3D line plot. Label and format the plot including axis labels, tittle, and legends so that you can
clearly communicate the solution.
Problem 4 (Matlab)
t (initial: 0, final: 40π, interval: π/500)
x(t) = ¿
y(t) = sin ( √ 32 t )
z(t) = ¿
Make a 3D line plot. Label and format the plot including axis labels, tittle, and legends so that you can
clearly communicate the solution.
3D plotting
3D surface plot:
Problem 5 (Matlab)
x (initial: -2, final: 2, interval: 0.25)
y=x
2 2
F = x e−x − y
Make 3D surface plot for x, y and F. Label and format the plot including axis labels, and legends so that
you can clearly communicate the solution.
Problem 6 (Matlab)
x(initial: 1, final: 10, interval: 0.5)
y(initial: 1, final: 20, interval: 1)
Z = sin(x) + cos(y)
C = xy
Make 3D surface plot for x, y , Z and C. Label and format the plot including axis labels, and legends so
that you can clearly communicate the solution.
colorbar
Problem 7 (Matlab)
{
xb ,∧x <5
y=f ( x )= a √ x ,∧x=5
2
2c
,∧x >5
x
Where ,a=7 , b=12 ,∧c=21
Solve the equation using conditional coding using Matlab. Use function that takes any independent
variable as an input and returns the output y or f(x) depending on the value of x (1 to 10) as conditions
given in the equation. Plot y as x.
Problem 8 (Matlab)
Write a Matlab code using for loop to calculate the summation of consecutive numbers from 1, 2, ….., 49,
50.
Problem 9 (Matlab)
Write a Matlab code to calculate 7! using for/while loop.
Problem 10 (1-4) (Matlab)
10-1. A biomass growth of a certain bacterial species is governed by the reaction rate:
dX
=µX
dt
Where X is the biomass concentration (g/L), t is time, and µ is the specific reaction rate. The initial
concentration of the bacteria is X0 = 0.2 g/L, and μ = 0.1 s-1.
Plot the X(t) versus t graph. Label and format the plot including axis labels, and legends so that you can
clearly communicate the solution.
10-2. Solve the differential equation:
dY 2
=Y
dt
Where initial condition: Y0 = 0.15
Plot the Y(t) versus t graph. Label and format the plot including axis labels, and legends so that you can
clearly communicate the solution.
10-3. Solve the differential equation:
dY 2
=Y +Yt
dt
Where initial condition: Y0 = 1.5×10-14
Plot the Y(t) versus t graph. Label and format the plot including axis labels, and legends so that you can
clearly communicate the solution.
10-4. A biomass growth of a certain bacterial species is governed by the reaction rate:
dX
=µX
dt
Where X is the biomass concentration (g/L), t is time, and µ is the specific reaction rate. The initial
concentration of the bacteria is X0 = 1 g/L, and μ = 0.5 s-1.
Plot the X(t) versus t graph. Label and format the plot including axis labels, and legends so that you can
clearly communicate the solution.
Problem 11 (Matlab)
For consecutive reactions:
A K 1 B K 2C
→ →
Follows the rate equation given below:
d[A]
=−k 1 [ A]
dt
d [B]
=k 1 [ A ]−k 1 [B ]
dt
d [C]
=k 2 [B]
dt
Where [A], [B], [C] is the concentration (kmol/m3), t is time, k1 and k2 are the rate constants. The initial
concentrations are is [A0] = 5 kmol/m3, [B0] = 5 kmol/m3, [C0] = 0 kmol/m3, k1 = 0.5 s-1, and k1 = 0.3 s-1
Plot the [A], [B], [C] versus t graph. Label and format the plot including axis labels, and legends so that
you can clearly communicate the solution.