0% found this document useful (0 votes)
5 views1 page

Practice Questions 2024 April

Uploaded by

yashgandhi232003
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)
5 views1 page

Practice Questions 2024 April

Uploaded by

yashgandhi232003
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/ 1

Practice problems

MATLAB® for Engineers


Course Instructor: Shreyas Shenoy
10th April, 2024

1. Write a MATLAB® code to create a 3 × 3 matrix filled with random numbers. Slice
the matrix to extract the middle row and last column. Using these vectors, write a
MATLAB® function to calculate the dot product of two vectors, without using the
built-in dot function.

2. Generate a 5×5 matrix with sequential numbers from 1 to 25. Slice the matrix to obtain
a 2 × 2 matrix from the top-left corner and another from the bottom-right corner.

3. Create a MATLAB® script to calculate the factorial of a given integer using a for loop.

4. Write a MATLAB® function named RootMeanSquare to calculate the root mean square
(RMS) of an input vector.

5. Write a MATLAB® script to find the prime numbers within a given range using a while
loop.

6. Write a MATLAB® function to compute the angle between two vectors using the dot
product. You may use to the DotProduct function defined in question 1.

7. Write a MATLAB® function named MatMult to perform matrix multiplication without


using the built-in * operator.

8. Develop a MATLAB® script to find the greatest common divisor (GCD) of two numbers
using the Euclidean algorithm within a while loop.

9. Write a MATLAB® script to perform numerical integration of a function f (x) = x2


x4 +2x2 +5
in the interval [0, 10] using

(a) Trapezoidal rule


(b) Simpson’s 3/8th rule

Also, show the percentage relative error by comparing it with the analytical value.

10. Develop a MATLAB® script to generate a parametric plot of a cycloid curve defined by
the equations:

x(t) = r(t − sin(t))


y(t) = r(1 − cos(t))

where r is the radius of the generating circle and t varies from 0 to 4π. Customize the
plot by adding a title, axis labels, and setting appropriate limits for the axes.

You might also like