0% found this document useful (0 votes)
52 views2 pages

Assignment-3 MEE1006

Uploaded by

babysharmala
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)
52 views2 pages

Assignment-3 MEE1006

Uploaded by

babysharmala
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/ 2

MATLAB for Engineers (MEE1006)

I Semester, Session: 2024-25, B.Tech


Department of Mechanical Engineering, SAMM
Manipal University Jaipur

Assignment-3

(Release Date: 20th Dec 2024; Due Date: 6th Jan 2025)

Instructions to the students:


i. Follow the deadline to submit the assignment (late submissions will lead to deduction in
marks).
ii. Mode (hard/soft copy) of submission is dependent on the respective course instructor(s).

Q.1 Let B be a variable that contains the sentence MY NAME IS JOHN SMITH. Write the command
to extract NAME JOHN out of the string.

Q.2 Let's say you have two matrices 𝑋 and 𝑌:

1 2 3 7 8
𝑋=[ ] and 𝑌 = [ ]
4 5 6 9 10
Append matrices 𝑋 and 𝑌 horizontally to form a new matrix 𝑍.
Append matrices 𝑋 and 𝑌 vertically to form a new matrix 𝑊 if possible else justify your answer.

Q.3 Using a for loop in MATLAB, write a program to calculate the sum of the first 10 odd numbers.
Show the output.

Q.4 For 𝜃 ranging from 0 to 2 𝜋, displacement y is given below for different ranges of theta.
Write a MATLAB script using if else conditions and plot y w.r.t 𝜃 for all the ranges. Show the
plot.
6[2𝜃−0.5𝑠𝑖𝑛𝜃] 𝜋
𝑦= for 0 ≤ 𝜃 ≤
𝜋 2
𝜋 2𝜋
𝑦=6 for ≤𝜃≤
2 3
2𝜋 2𝜋 4𝜋
𝑦 = 6 − 3 [1 − 0.5 cos (3 (𝜃 − ))] for ≤𝜃≤
3 3 3
4𝜋 3𝜋
𝑦=3 for ≤𝜃≤
3 2
3𝜋 2
𝜃− 3𝜋 7𝜋
2
𝑦 = 3 − 1.5 ( 𝜋 ) for ≤𝜃≤
2 4
4
𝑡−7𝜋/4 2 7𝜋
𝑦 = 0.75 − 0.75 (1 − ) for ≤ 𝜃 ≤ 2𝜋
𝜋/4 4

Q.5 Consider a polynomial 𝑓(𝑥) = 3𝑥 3 − 2𝑥 2 + 5𝑥 − 7.


i. Define this polynomial as a MATLAB function named ‘polynomial_f’ that takes x as input
and returns the value of 𝑓(𝑥).
ii. Write MATLAB code to evaluate 𝑓(𝑥) at 𝑥 = 2.
iii. Write MATLAB code to find the roots of 𝑓(𝑥).
Plot the graph of 𝑓(𝑥) in the range 𝑥 ∈ [−3,3] with 100 elements. Show the output.
Page 1 of 2
Q.6 Given the following data points:

Days 0 5 10 15 20
Height
0.2 0.8 1.5 2.3 3.0
(meters)

Write a MATLAB code to perform the curve fitting using a second-degree polynomial. Show
the output.
Q.7 For the give scattered data, write MATLAB codes for the following curve fitting
operations:
a) 5 degrees polynomial (represented by ‘-’)
b) 4 degrees polynomial (represented by ‘--‘)
(0.3, 0.7), (1.3,1.2), (3.1, 2.2), 4,5), (6.4, 5.4), (7.6, 4.6), (8.1, 4.9), 8.4, 5), (9.1, 5.9), (9.8, 6.8)
Show x-axis and y-axis labels as ‘x’ and ‘y’ respectively and show the output.
Q.8 The overall grade in a course is determined from the grades of 6 quizzes, 3 midterms, and a final
exam, using the following scheme: Quizzes: Quizzes are graded on a scale from 0 to 10. The grade of
the lowest quiz is dropped and the average of the 5 quizzes with the higher grades constitutes 30% of
the course grade. Midterms and final exam: Midterms and final exams are graded on a scale from 0 to
100. If the average of the midterm scores is higher than the score of the final exam, the average of the
midterms constitutes 50% of the course grade and the grade of the final exam constitutes 20% of the
course grade. If the final grade is higher than the average of the midterms, the average of the midterms
constitutes 20% of the course grade and the grade of the final exam constitutes 50% of the course
grade. Write a MATLAB script that determines the course grade for a student. The program first asks
the user to enter the six quiz grades (in a vector), the three midterm grades (in a vector), and the grade
of the final exam. Then the program calculates a numerical course grade (a number between 0 and
100). Finally, the program assigns a letter grade according to the following key: 𝐺𝑟𝑎𝑑𝑒 A for ≥ 90, B
for 80 ≤ 𝐺𝑟𝑎𝑑𝑒 < 90, C for 70 ≤ 𝐺𝑟𝑎𝑑𝑒 < 80, D for 60 ≤ 𝐺𝑟𝑎𝑑𝑒 < 70, and E for a grade lower than
60. Execute the program for the following cases: (a) Quiz grades: 6, 10, 6, 8, 7, 8. Midterm grades:
82, 95, 89. Final exam: 81. (b) Quiz grades: 9, 5, 8, 8, 7, 6. Midterm grades: 78, 82, 75. Final exam:
81.

Q.9 Given the differential equation:

𝑑2𝑦 𝑑𝑥
2
+ 12 + 15𝑥 = 35; 𝑡 ≥ 0
𝑑𝑡 𝑑𝑡
Using MATLAB program, find:

𝑥(𝑡) when 𝑥(0) = 0 and 𝑥̇ (0) = 1.

Page 2 of 2

You might also like