Assignment-3_MEE1006
Assignment-3_MEE1006
Assignment-3
(Release Date: 20th Dec 2024; Due Date: 6th Jan 2025)
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.
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
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.
𝑑2𝑦 𝑑𝑥
2
+ 12 + 15𝑥 = 35; 𝑡 ≥ 0
𝑑𝑡 𝑑𝑡
Using MATLAB program, find:
Page 2 of 2