The University of Jordan
School of Engineering
Mechanical Engineering Department
ME 0914202 Computer Programming for Engineers
Classwork #02 - Section 1
Name: Spring 2023/2024
ID Number: Date: 17/03/2024
Problem 1. Using MATLAB, plot the function $f(x) = x^3 - 2x^2 + x$, where x ranges from -10 to 10 with
a step of 0.1. Your final plot should be green, dashed line, with a circle marker. The xlabel is 'x', the ylabel
is 'F(x)', and the title is 'My Plot', with grid on.
Solution:
Problem 2. Using MATLAB, generate a surface plot of the function $f(x, y) = \sin(x) \cdot \cos(y)$, over the
interval [-5, 5] for both x and y.
Solution:
Problem 3. Write a MATLAB function called 'calculate_factorial' that computes and returns the factorial
of a given non-negative integer.
Solution:
Problem 4. Create a subplot with size of (1x2). In the first plot, plot the function $f(x) = e^x$, and in the
second plot, plot the function $f(x) = x^2$. Customize the color, linestyle, and markers of the plots in
however you prefer.
Solution: