SlideShare a Scribd company logo
1 of 10
Download to read offline
1
MATH 251 MIDTERM I
Answers
1. A=[ 3 4 5 6 7 ; 13 14 15 16 17]
2. A=[ [3:7] ; [13:17] ]
Pookie =
4 6
2 3
Pookie (1,1) + Pookie (2,2) = 4 + 3 = 7
2
V=[ A(:,1) ' A(:,2) ' A(:,3) ' ] '
U=[ A(1,:) A(2,:) A(3,:) ] '
W=[A(1,:) A(:,3)']
3
B='MY NAME IS JOHN SMITH'
B(12:15)='BILL'
>> A1=zeros(2,3);
>> A2=ones(2);
>> A3=eye(5);
>> A=[A1 A2;A3];
Page 1 of 4
Solutions Mid 2-
Question 1:
Give the steps to solve the following system of linear equations using MATLAB.
2x-3y+4z=5
y+4z+x=10
-2z+3x+4y=0
>> A=[2 -3 4; 1 1 4; 3 4 -2];
>> B=[5;10;0];
>> X=inv(A)*B
Question 2:
(A)
>> x=[-5:0.1:5];y=[-5:0.1:5];
>> [A,B]=meshgrid(x,y);
>> Z=-(A/5).^2-(B/2).^2-16;
>> surf(A,B,Z)
>> colormap gray
>> xlabel('X-Axis'); ylabel('Y-Axis');
>> title('Question-2 of Midterm 2')
>> grid off
- (B)Give MATLAB commands to plot, on the same figure, the two functions:
Where the variable t varies from 0 to 10 with step 0.5
- Draw the function f in blue 0 and the function g in red *
- Give title to your graph and label the axes.
>> t=[0:0.5:10];
>> f=3*t.^2+2*t-0.5;
>> g=2*t.*cos(t);
4
6
Page 2 of 4
>> plot(t,f,'ob',t,g,'*r')
>> title('Question 3-B of Mid2')
>> xlabel('t values');
Question 3:
function Z=Question3(x,y)
Z=exp(x).*cos(y)+sin(x.^2-y);
>> Question3(-3,4)
>> Question3(-5,-7)
>> x=-pi:0.1:pi;
>> y=-pi:0.1:pi;
>> z=Question3(x,y);
>> plot3(x,y,z)
(B) Write a M-File to calculate the square root of each element of the vector
v=16,10,34. Display the results in the form: “The square root is v” with a total of 6
digits with 2 digits after the decimal point.
v=[16 10 34];
r=sqrt(v);
fprintf('The square root is %f6.2n',r);
5
Page 1 of 5
Type: Closed Book.
Additional Materials: NO ADDITIONAL MATERIALS ALLOWED
Instructions:
1. Answer all questions; there are 5 pages.
2. Write your answers directly on the question sheets. Use the ends or back of the
question pages for rough work or if you need extra space for your answer.
3. If information appears to be missing from a question, make a reasonable
assumption, state your assumption, and proceed.
4. Books and notes are banned. You cannot use MATLAB software for this exam.
5. If you are not sure what a question means, raise your hand and ask me.
6. Write your name in the space provided below on this page and your initials at the top
of each subsequent page.
For examiner
Question Mark Out of
Question 1 4.5
Question 2 4.5
Question 3 8
Question 4 3
Total 20
‫السعودية‬ ‫العربية‬ ‫المملكة‬
‫العالي‬ ‫التعليم‬ ‫وزارة‬
‫اإلسالمية‬ ‫سعود‬ ‫بن‬ ‫محمد‬ ‫اإلمام‬ ‫جامعة‬
‫كلية‬
‫ال‬
‫علوم‬
EXAM : MIDTERM I
YEAR: 1433-1434H (SEM 2ND
)
COURSE NUMBER: MATH 251
DATE:01/05/1433H
DURATION: 1 HOUR
INSTRUCTOR: Dr. Mohammed Messaoudi
Name Id number Group
Page 2 of 5
Question 1:
I. Choose the correct answer (1)
1. Suppose x is a new variable, with the following MATLAB command,
>> x = [-10:-1:-15; -2:3];
What the is the size of x?
x =
-10 -11 -12 -13 -14 -15
-2 -1 0 1 2 3
Answer: >> size of x is 2 (rows) 6 ( columns)
2. A matrix was generated using (1)
>> M = ceil(10.4);
Which of the following statement is not valid in MATLAB?
a. M + M *2
b. sin(M)
c. exp(M)
d. M(1,:) ^ 2
e. error
II. What is the output from the following MATLAB Commands?
1. >> a = 3;b = 2; c = a + b (1/2)
c=5
2. >> d = 1:5; 2*d(3:4) (1/2)
6 8
3. >> who (1/2)
a b c d
IV. What is the difference between clc and clear commands? (1)
clc : clears the screen,
clear: deletes all variables from memory
4.5
Page 3 of 5
Question 2:
I. Are the following variable assignment is correct? If no, explain why?
(1.5)
 Two_2 (correct) √
 example1_1 √
 max a MATLAB function X
 cos_2 √
 which √
 M251 √
II. Find the mistake in the following commands and correct them. (3)
>>P =linespace(2,3) P =linspace(2,3)
>>P[ 1, 2] = 4 P(1, 2) = 4
>>K= ones(1;3) ones(1,3)
K=
4.5
Page 4 of 5
Question 3:
I .Let [ ] [ ] [ ] [ ]
[ ]
(5)
1. Write a command for matrix Multiplication of CD
C.*D
2. Write a command to arrange the element of the vector E in ascending order.
sort(E)
3. Write a command to return the smallest element of vector E.
min(E)
4. Delete 2nd
column from matrix C.
C(:,2)=[]
5. Use Left division to solve X = A-1
B
X = AB
II. Create a matrix in the middle two rows, and the middle two columns are
3's and the rest are 4's. (3)
A=4*ones(6,6);
A(:,3:4)=3;
A(3:4,:)=3;
Question 4:
I. Ali went to the market. He bought 5kg of carrots (4SR/kg), 2kg of apples (7SR/kg), 6
lettuces (2 for 4SR) and 6 Pepsi (2SR each). What is the total amount?
>> total = 5*4 + 2*7 + 6/2*4 + 6*2 (1)
8
3
Page 5 of 5
II. Write the MATLAB command for the following line
a. | ( )| for a = 11 , b = and X = {2,4,6,8}
>>a=11; b=pi; X =[2 4 6 8]; (2)
>>Y=abs(X.*exp(a*X)-cos(b*X));

More Related Content

What's hot

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabTarun Gehlot
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical ComputingNaveed Rehman
 
Master method
Master method Master method
Master method Rajendran
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to MatlabTariq kanher
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introductionAmeen San
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabBilawalBaloch1
 
DOUBLE INTEGRALS PPT GTU CALCULUS (2110014)
DOUBLE INTEGRALS PPT GTU CALCULUS (2110014) DOUBLE INTEGRALS PPT GTU CALCULUS (2110014)
DOUBLE INTEGRALS PPT GTU CALCULUS (2110014) Panchal Anand
 
MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1Elaf A.Saeed
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabSantosh V
 
Matlab-Data types and operators
Matlab-Data types and operatorsMatlab-Data types and operators
Matlab-Data types and operatorsLuckshay Batra
 
My Lecture Notes from Linear Algebra
My Lecture Notes fromLinear AlgebraMy Lecture Notes fromLinear Algebra
My Lecture Notes from Linear AlgebraPaul R. Martin
 
Lab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicLab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicKatrina Little
 
Gate mathematics chapter wise all gate questions of all branch
Gate mathematics chapter wise all gate questions of all branchGate mathematics chapter wise all gate questions of all branch
Gate mathematics chapter wise all gate questions of all branchdataniyaarunkumar
 
User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1Shameer Ahmed Koya
 
Linear Combination, Span And Linearly Independent, Dependent Set
Linear Combination, Span And Linearly Independent, Dependent SetLinear Combination, Span And Linearly Independent, Dependent Set
Linear Combination, Span And Linearly Independent, Dependent SetDhaval Shukla
 

What's hot (20)

Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
MATLAB for Technical Computing
MATLAB for Technical ComputingMATLAB for Technical Computing
MATLAB for Technical Computing
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Master method
Master method Master method
Master method
 
Brief Introduction to Matlab
Brief  Introduction to MatlabBrief  Introduction to Matlab
Brief Introduction to Matlab
 
Matlab introduction
Matlab introductionMatlab introduction
Matlab introduction
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
DOUBLE INTEGRALS PPT GTU CALCULUS (2110014)
DOUBLE INTEGRALS PPT GTU CALCULUS (2110014) DOUBLE INTEGRALS PPT GTU CALCULUS (2110014)
DOUBLE INTEGRALS PPT GTU CALCULUS (2110014)
 
MATLAB Basics-Part1
MATLAB Basics-Part1MATLAB Basics-Part1
MATLAB Basics-Part1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
Matlab-Data types and operators
Matlab-Data types and operatorsMatlab-Data types and operators
Matlab-Data types and operators
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
My Lecture Notes from Linear Algebra
My Lecture Notes fromLinear AlgebraMy Lecture Notes fromLinear Algebra
My Lecture Notes from Linear Algebra
 
Lab 2-Simple Combinational Logic
Lab 2-Simple Combinational LogicLab 2-Simple Combinational Logic
Lab 2-Simple Combinational Logic
 
Gate mathematics chapter wise all gate questions of all branch
Gate mathematics chapter wise all gate questions of all branchGate mathematics chapter wise all gate questions of all branch
Gate mathematics chapter wise all gate questions of all branch
 
User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1User defined Functions in MATLAB Part 1
User defined Functions in MATLAB Part 1
 
Linear Combination, Span And Linearly Independent, Dependent Set
Linear Combination, Span And Linearly Independent, Dependent SetLinear Combination, Span And Linearly Independent, Dependent Set
Linear Combination, Span And Linearly Independent, Dependent Set
 

Similar to MATH 251 MIDTERM I SOLUTIONS

11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx
11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx
11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docxhyacinthshackley2629
 
---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf
---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf
---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdfuroosavayani
 
Day 4 order of operations
Day 4 order of operationsDay 4 order of operations
Day 4 order of operationsErik Tjersland
 
Day 7 distributive property
Day 7 distributive propertyDay 7 distributive property
Day 7 distributive propertyErik Tjersland
 
Onlinetest360.com quantitative aptitude PDF
Onlinetest360.com quantitative aptitude PDFOnlinetest360.com quantitative aptitude PDF
Onlinetest360.com quantitative aptitude PDFonlinetest
 
CJA474 v9Effective Practices for Managers and Supervisors CJA.docx
CJA474 v9Effective Practices for Managers and Supervisors CJA.docxCJA474 v9Effective Practices for Managers and Supervisors CJA.docx
CJA474 v9Effective Practices for Managers and Supervisors CJA.docxmccormicknadine86
 
Bc Math 10 Functions and Slope Practice Test
Bc Math 10 Functions and Slope Practice TestBc Math 10 Functions and Slope Practice Test
Bc Math 10 Functions and Slope Practice TestHun Kim
 
BC Math 10 Exponents Practice Test
BC Math 10 Exponents Practice TestBC Math 10 Exponents Practice Test
BC Math 10 Exponents Practice TestHun Kim
 
Sept. 15, 2014
Sept. 15, 2014Sept. 15, 2014
Sept. 15, 2014khyps13
 
Maths: Subtraction Worksheet (CBSE Grade II )
Maths: Subtraction Worksheet (CBSE Grade II )Maths: Subtraction Worksheet (CBSE Grade II )
Maths: Subtraction Worksheet (CBSE Grade II )theeducationdesk
 
Math4 q3 module4-final_v4
Math4 q3 module4-final_v4Math4 q3 module4-final_v4
Math4 q3 module4-final_v4KitVillarubia
 

Similar to MATH 251 MIDTERM I SOLUTIONS (20)

11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx
11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx
11414 2.3 Homework (Quadratic Equations)courses.thinkwel.docx
 
order of operations
order of operationsorder of operations
order of operations
 
---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf
---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf
---Orientation-Session---Business-Statistics-22092023-044926pm (2).pdf
 
Assignment1
Assignment1Assignment1
Assignment1
 
Matlab quick quide3.4
Matlab  quick quide3.4Matlab  quick quide3.4
Matlab quick quide3.4
 
Aaa
AaaAaa
Aaa
 
Day 4 order of operations
Day 4 order of operationsDay 4 order of operations
Day 4 order of operations
 
Arithmetic sequence
Arithmetic sequenceArithmetic sequence
Arithmetic sequence
 
Day 7 distributive property
Day 7 distributive propertyDay 7 distributive property
Day 7 distributive property
 
Onlinetest360.com quantitative aptitude PDF
Onlinetest360.com quantitative aptitude PDFOnlinetest360.com quantitative aptitude PDF
Onlinetest360.com quantitative aptitude PDF
 
CJA474 v9Effective Practices for Managers and Supervisors CJA.docx
CJA474 v9Effective Practices for Managers and Supervisors CJA.docxCJA474 v9Effective Practices for Managers and Supervisors CJA.docx
CJA474 v9Effective Practices for Managers and Supervisors CJA.docx
 
Bc Math 10 Functions and Slope Practice Test
Bc Math 10 Functions and Slope Practice TestBc Math 10 Functions and Slope Practice Test
Bc Math 10 Functions and Slope Practice Test
 
Matlab-1.pptx
Matlab-1.pptxMatlab-1.pptx
Matlab-1.pptx
 
BC Math 10 Exponents Practice Test
BC Math 10 Exponents Practice TestBC Math 10 Exponents Practice Test
BC Math 10 Exponents Practice Test
 
ASSESSMENT M105 (1).pdf
ASSESSMENT M105 (1).pdfASSESSMENT M105 (1).pdf
ASSESSMENT M105 (1).pdf
 
Sept. 15, 2014
Sept. 15, 2014Sept. 15, 2014
Sept. 15, 2014
 
Lesson plan exponents and powers class VIII
Lesson plan exponents and powers class VIIILesson plan exponents and powers class VIII
Lesson plan exponents and powers class VIII
 
Maths: Subtraction Worksheet (CBSE Grade II )
Maths: Subtraction Worksheet (CBSE Grade II )Maths: Subtraction Worksheet (CBSE Grade II )
Maths: Subtraction Worksheet (CBSE Grade II )
 
Math4 q3 module4-final_v4
Math4 q3 module4-final_v4Math4 q3 module4-final_v4
Math4 q3 module4-final_v4
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 

MATH 251 MIDTERM I SOLUTIONS

  • 1. 1 MATH 251 MIDTERM I Answers 1. A=[ 3 4 5 6 7 ; 13 14 15 16 17] 2. A=[ [3:7] ; [13:17] ] Pookie = 4 6 2 3 Pookie (1,1) + Pookie (2,2) = 4 + 3 = 7
  • 2. 2 V=[ A(:,1) ' A(:,2) ' A(:,3) ' ] ' U=[ A(1,:) A(2,:) A(3,:) ] ' W=[A(1,:) A(:,3)']
  • 3. 3 B='MY NAME IS JOHN SMITH' B(12:15)='BILL' >> A1=zeros(2,3); >> A2=ones(2); >> A3=eye(5); >> A=[A1 A2;A3];
  • 4. Page 1 of 4 Solutions Mid 2- Question 1: Give the steps to solve the following system of linear equations using MATLAB. 2x-3y+4z=5 y+4z+x=10 -2z+3x+4y=0 >> A=[2 -3 4; 1 1 4; 3 4 -2]; >> B=[5;10;0]; >> X=inv(A)*B Question 2: (A) >> x=[-5:0.1:5];y=[-5:0.1:5]; >> [A,B]=meshgrid(x,y); >> Z=-(A/5).^2-(B/2).^2-16; >> surf(A,B,Z) >> colormap gray >> xlabel('X-Axis'); ylabel('Y-Axis'); >> title('Question-2 of Midterm 2') >> grid off - (B)Give MATLAB commands to plot, on the same figure, the two functions: Where the variable t varies from 0 to 10 with step 0.5 - Draw the function f in blue 0 and the function g in red * - Give title to your graph and label the axes. >> t=[0:0.5:10]; >> f=3*t.^2+2*t-0.5; >> g=2*t.*cos(t); 4 6
  • 5. Page 2 of 4 >> plot(t,f,'ob',t,g,'*r') >> title('Question 3-B of Mid2') >> xlabel('t values'); Question 3: function Z=Question3(x,y) Z=exp(x).*cos(y)+sin(x.^2-y); >> Question3(-3,4) >> Question3(-5,-7) >> x=-pi:0.1:pi; >> y=-pi:0.1:pi; >> z=Question3(x,y); >> plot3(x,y,z) (B) Write a M-File to calculate the square root of each element of the vector v=16,10,34. Display the results in the form: “The square root is v” with a total of 6 digits with 2 digits after the decimal point. v=[16 10 34]; r=sqrt(v); fprintf('The square root is %f6.2n',r); 5
  • 6. Page 1 of 5 Type: Closed Book. Additional Materials: NO ADDITIONAL MATERIALS ALLOWED Instructions: 1. Answer all questions; there are 5 pages. 2. Write your answers directly on the question sheets. Use the ends or back of the question pages for rough work or if you need extra space for your answer. 3. If information appears to be missing from a question, make a reasonable assumption, state your assumption, and proceed. 4. Books and notes are banned. You cannot use MATLAB software for this exam. 5. If you are not sure what a question means, raise your hand and ask me. 6. Write your name in the space provided below on this page and your initials at the top of each subsequent page. For examiner Question Mark Out of Question 1 4.5 Question 2 4.5 Question 3 8 Question 4 3 Total 20 ‫السعودية‬ ‫العربية‬ ‫المملكة‬ ‫العالي‬ ‫التعليم‬ ‫وزارة‬ ‫اإلسالمية‬ ‫سعود‬ ‫بن‬ ‫محمد‬ ‫اإلمام‬ ‫جامعة‬ ‫كلية‬ ‫ال‬ ‫علوم‬ EXAM : MIDTERM I YEAR: 1433-1434H (SEM 2ND ) COURSE NUMBER: MATH 251 DATE:01/05/1433H DURATION: 1 HOUR INSTRUCTOR: Dr. Mohammed Messaoudi Name Id number Group
  • 7. Page 2 of 5 Question 1: I. Choose the correct answer (1) 1. Suppose x is a new variable, with the following MATLAB command, >> x = [-10:-1:-15; -2:3]; What the is the size of x? x = -10 -11 -12 -13 -14 -15 -2 -1 0 1 2 3 Answer: >> size of x is 2 (rows) 6 ( columns) 2. A matrix was generated using (1) >> M = ceil(10.4); Which of the following statement is not valid in MATLAB? a. M + M *2 b. sin(M) c. exp(M) d. M(1,:) ^ 2 e. error II. What is the output from the following MATLAB Commands? 1. >> a = 3;b = 2; c = a + b (1/2) c=5 2. >> d = 1:5; 2*d(3:4) (1/2) 6 8 3. >> who (1/2) a b c d IV. What is the difference between clc and clear commands? (1) clc : clears the screen, clear: deletes all variables from memory 4.5
  • 8. Page 3 of 5 Question 2: I. Are the following variable assignment is correct? If no, explain why? (1.5)  Two_2 (correct) √  example1_1 √  max a MATLAB function X  cos_2 √  which √  M251 √ II. Find the mistake in the following commands and correct them. (3) >>P =linespace(2,3) P =linspace(2,3) >>P[ 1, 2] = 4 P(1, 2) = 4 >>K= ones(1;3) ones(1,3) K= 4.5
  • 9. Page 4 of 5 Question 3: I .Let [ ] [ ] [ ] [ ] [ ] (5) 1. Write a command for matrix Multiplication of CD C.*D 2. Write a command to arrange the element of the vector E in ascending order. sort(E) 3. Write a command to return the smallest element of vector E. min(E) 4. Delete 2nd column from matrix C. C(:,2)=[] 5. Use Left division to solve X = A-1 B X = AB II. Create a matrix in the middle two rows, and the middle two columns are 3's and the rest are 4's. (3) A=4*ones(6,6); A(:,3:4)=3; A(3:4,:)=3; Question 4: I. Ali went to the market. He bought 5kg of carrots (4SR/kg), 2kg of apples (7SR/kg), 6 lettuces (2 for 4SR) and 6 Pepsi (2SR each). What is the total amount? >> total = 5*4 + 2*7 + 6/2*4 + 6*2 (1) 8 3
  • 10. Page 5 of 5 II. Write the MATLAB command for the following line a. | ( )| for a = 11 , b = and X = {2,4,6,8} >>a=11; b=pi; X =[2 4 6 8]; (2) >>Y=abs(X.*exp(a*X)-cos(b*X));