SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
1/3Smee
Matlab (TP1) 25%pt
1. Vectors and Matrices Initialize the following variables:
A=[
5 … 5
⋮ ⋱ ⋮
5 … 5
]
9×9
(use ones,zeros) ,B= (A 9x9 matrix of all 0 but with the values [1 2 3 4 5 4 3 2 1] on
diagonal, use zeros, diag) C= (A 3x4 matrix, use NaN) ,D=
2. Define the vector V = [0 1 2 ... 39 40]. What is the size of this vector? Define the vector W containing the first five and the last
five elements of V then define the vector Z = [0 2 4 ... 38 40] from V.
3. Define the matrix What are its dimensions m x n? Extract from this matrix
and .. Make a matrix Q obtained by taking the matrix M intersected between all the 3rd
rows
and one column out of 2. Calculate the matrix products NP = N x P, NtQ = N 'x Q and NQ = N x Q, then comment the results.
4. Define the variable 𝑥 = [
𝜋
6
,
𝜋
4
,
𝜋
3
] and calculate y1=sin(x) and y2=cos(x) Then calculate tan(x) using only the previous y1 and y2.
5. The following vectors are considered:
𝑢 = (
1
2
3
) , 𝑣 = (
−5
2
1
) 𝑎𝑛𝑑 𝑤 = (
−1
−3
7
)
a. Calculate t=u+3v-5w
b. Calculate ‖𝑢‖, ‖𝑣‖, ‖𝑤‖ and the cosine of the angle α formed by the vectors u and v, and α in degrees.
6. Application:This problem requires you to generate temperature conversion tables. Use the following equations, which describe
the relationships between tempera-tures in degrees Fahrenheit(TF) , degrees Celsius(TC), kelvins( TK ) , and degrees Rankine
(TR ) , respectively: 𝑇𝐹 = 𝑇𝑅 − 459.67 𝑜
𝑅, 𝑇𝐹 =
9
5
𝑇𝐶 + 32 𝑜
𝐹, 𝑇𝑅 =
9
5
𝑇𝑘 You will need to rearrange these expressions to solve
some of the problems.
(a) Generate a table of conversions from Fahrenheit to Kelvin for values from 0°F to 200°F. Allow the user to enter the
increments in degrees F between lines. Use disp and fprintf to create a table with a title, column headings, and appropriate
spacing.
(b) Generate a table of conversions from Celsius to Rankine. Allow the user to enter the starting temperature and the increment
between lines. Print 25 lines in the table. Use disp and fprintf to create a table with a title, column headings, and appropriate
spacing.
(c) Generate a table of conversions from Celsius to Fahrenheit. Allow the user to enter the starting temperature, the increment
between lines, and the number of lines for the table. Use disp and fprintf to create a table with a title, column headings, and
appropriate spacing.
7. Defined function Write in Matlab to find roots of quadratic equation 𝑦 = 𝑎𝑥2
+ 𝑏𝑥 + 𝑐 by contained the roots 𝑥 = [𝑥1 𝑥2].
Now, apply your program for the following cases:
a. a=1,b=7,c=12 b. a=1,b=-4,c=4 c. a=1,b=2,c=3
8. Using a function to calculate the volume of liquid (V) in a spherical tank,
given the depth of the liquid (h) and the radius (R).
V=SphereTank(R,h)
Now, apply your program for the following cases:
a. R=2,h=1 b. R=h=5 𝑉 =
𝜋ℎ2(3𝑅−ℎ)
3
2/3Smee
Solution
1.
A=5*ones(9) or A=5.+zeros(5,5)
B. a=[1:5,4:-1:1]
b=diag(a)
c=zeros(9,9)
D=b+c
or D=diag([1:5,4:-1:1])+zeros(9,9)
C=NaN(3,4)
D=([1:10;11:20;21:30;31:40;41:50;51:60;61:70;71:80;81:90;91:100])'
2.
V=[0:40]
size(V)
W=[V(:,1:5) V(:,37:41)]
Z=V(:,[1:2:40])
3.
M=[1:10;11:20;21:30]
size(M)
N=M(:,1:2)
P=M([1 3],[3 7])
Q=M(:,[1:2:10])
NP=N*P
NtQ=N'*Q
NQ=
%Error because both its size is not available for multiple matric
4.
x=[pi/6 pi/4 pi/3]
y1=sin(x)
y2=cos(x)
y=y1./y2
5.
u=[1;2;3]
v=[-5;2;1]
w=[-1;-3;7]
t=u+3*v-5*w
U=norm(u)
V=norm(v)
W=norm(w)
z=dot(u,v);
a=z/[U*V]
b=acosd(a)
6.
a.
incr=input('put the value of the incressing temperature')
F=0:incr:200;
K=(5.*(F+459.67)./9);
table=[F;K];
disp('Conversions from Fahrenheit to kelvin')
disp('In_F conversion to Kelvin')
fprintf('%3.4f %3.4frn',table);
b.
S=input('put the value of the starting temperature')
C=linspace(S,200,25);
R=(C+273.15).*1.8;
table=[C;R];
disp('Conversions from C to Rekin')
3/3Smee
disp('In_C conversion to Rekin')
fprintf('%3.4f %3.4frn',table);
c.
S=input('put the value of the starting temperature')
incr=input('put the value of the incressing temperature')
C=linspace(S,200,incr);
F=1.8.*C+32
table=[C;F];
disp('Conversions from C to F')
disp('In_C conversion to F')
fprintf('%3.4f %3.4frn',table);
7. Defined Function
function x = quadratic(a,b,c)
delta = 4*a*c;
denom = 2*a;
rootdisc = sqrt(b.^2 - delta); % Square root of the discriminant
x1 = (-b + rootdisc)./denom;
x2 = (-b - rootdisc)./denom;
x = [x1 x2];
end
Comment Window
quadratic(1,7,12)
quadratic(1,-4,4)
quadratic(1,2,3)
8.
function volume=SphereTank(radius,depth)
volume= pi*depth.^2*(3.*radius-depth)/3;
end
Comment Window
SphereTank(2,1)
SphereTank(5,5)
______________________________________________________________________________________________________________________
8/13/2017
5:32PM
Corrected by
Mr.Smee Kaem Chann
Tel : +885965235960

Weitere ähnliche Inhalte

Was ist angesagt?

lecture 15
lecture 15lecture 15
lecture 15
sajinsc
 
Matrices
MatricesMatrices
Matrices
daferro
 
Basic concepts. Systems of equations
Basic concepts. Systems of equationsBasic concepts. Systems of equations
Basic concepts. Systems of equations
jorgeduardooo
 

Was ist angesagt? (19)

Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Goldie chapter 4 function
Goldie chapter 4 functionGoldie chapter 4 function
Goldie chapter 4 function
 
Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6
 
lecture 15
lecture 15lecture 15
lecture 15
 
Matrices
MatricesMatrices
Matrices
 
Basic concepts. Systems of equations
Basic concepts. Systems of equationsBasic concepts. Systems of equations
Basic concepts. Systems of equations
 
4R2012 preTest12A
4R2012 preTest12A4R2012 preTest12A
4R2012 preTest12A
 
algo1
algo1algo1
algo1
 
Trigonometric functions
Trigonometric functionsTrigonometric functions
Trigonometric functions
 
Karnaugh maps
Karnaugh mapsKarnaugh maps
Karnaugh maps
 
Karnaugh maps
Karnaugh mapsKarnaugh maps
Karnaugh maps
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
4R2012 preTest11A
4R2012 preTest11A4R2012 preTest11A
4R2012 preTest11A
 
08 mtp11 applied mathematics - dec 2009,jan 2010
08 mtp11  applied mathematics - dec 2009,jan 201008 mtp11  applied mathematics - dec 2009,jan 2010
08 mtp11 applied mathematics - dec 2009,jan 2010
 
Differential Equations Homework Help
Differential Equations Homework HelpDifferential Equations Homework Help
Differential Equations Homework Help
 
Matrices
MatricesMatrices
Matrices
 
4R2012 preTest2A
4R2012 preTest2A4R2012 preTest2A
4R2012 preTest2A
 
Differential Equations Assignment Help
Differential Equations Assignment HelpDifferential Equations Assignment Help
Differential Equations Assignment Help
 
Matlab lecture 6 – newton raphson method@taj copy
Matlab lecture 6 – newton raphson method@taj   copyMatlab lecture 6 – newton raphson method@taj   copy
Matlab lecture 6 – newton raphson method@taj copy
 

Ähnlich wie Travaux Pratique Matlab + Corrige_Smee Kaem Chann

MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
andreecapon
 
Q1Perform the two basic operations of multiplication and divisio.docx
Q1Perform the two basic operations of multiplication and divisio.docxQ1Perform the two basic operations of multiplication and divisio.docx
Q1Perform the two basic operations of multiplication and divisio.docx
amrit47
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
anhlodge
 
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
smile790243
 
M210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docx
M210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docxM210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docx
M210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docx
smile790243
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
Devaraj Chilakala
 

Ähnlich wie Travaux Pratique Matlab + Corrige_Smee Kaem Chann (20)

MATLAB review questions 2014 15
MATLAB review questions 2014 15MATLAB review questions 2014 15
MATLAB review questions 2014 15
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Q1Perform the two basic operations of multiplication and divisio.docx
Q1Perform the two basic operations of multiplication and divisio.docxQ1Perform the two basic operations of multiplication and divisio.docx
Q1Perform the two basic operations of multiplication and divisio.docx
 
Algorithm Homework Help
Algorithm Homework HelpAlgorithm Homework Help
Algorithm Homework Help
 
Matlab practice
Matlab practiceMatlab practice
Matlab practice
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Programming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EESProgramming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EES
 
A02
A02A02
A02
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
 
M210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docx
M210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docxM210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docx
M210 Songyue.pages__MACOSX._M210 Songyue.pagesM210-S16-.docx
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
COMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptxCOMPANION TO MATRICES SESSION II.pptx
COMPANION TO MATRICES SESSION II.pptx
 
Matlab intro notes
Matlab intro notesMatlab intro notes
Matlab intro notes
 
NCIT civil Syllabus 2013-2014
NCIT civil Syllabus 2013-2014NCIT civil Syllabus 2013-2014
NCIT civil Syllabus 2013-2014
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Linear Algebra Assignment help
Linear Algebra Assignment helpLinear Algebra Assignment help
Linear Algebra Assignment help
 
Calculus Assignment Help
 Calculus Assignment Help Calculus Assignment Help
Calculus Assignment Help
 
Tarea1
Tarea1Tarea1
Tarea1
 

Mehr von Smee Kaem Chann

Mehr von Smee Kaem Chann (20)

stress-and-strain
stress-and-strainstress-and-strain
stress-and-strain
 
Robot khmer engineer
Robot khmer engineerRobot khmer engineer
Robot khmer engineer
 
15 poteau-2
15 poteau-215 poteau-2
15 poteau-2
 
14 poteau-1
14 poteau-114 poteau-1
14 poteau-1
 
12 plancher-Eurocode 2
12 plancher-Eurocode 212 plancher-Eurocode 2
12 plancher-Eurocode 2
 
Matlab_Prof Pouv Keangsé
Matlab_Prof Pouv KeangséMatlab_Prof Pouv Keangsé
Matlab_Prof Pouv Keangsé
 
Vocabuary
VocabuaryVocabuary
Vocabuary
 
Journal de bord
Journal de bordJournal de bord
Journal de bord
 
8.4 roof leader
8.4 roof leader8.4 roof leader
8.4 roof leader
 
Rapport de stage
Rapport de stage Rapport de stage
Rapport de stage
 
Td triphasé
Td triphaséTd triphasé
Td triphasé
 
Tp2 Matlab
Tp2 MatlabTp2 Matlab
Tp2 Matlab
 
Cover matlab
Cover matlabCover matlab
Cover matlab
 
New Interchange 3ed edition Vocabulary unit 8
New Interchange 3ed edition Vocabulary unit 8 New Interchange 3ed edition Vocabulary unit 8
New Interchange 3ed edition Vocabulary unit 8
 
Matlab Travaux Pratique
Matlab Travaux Pratique Matlab Travaux Pratique
Matlab Travaux Pratique
 
The technologies of building resists the wind load and earthquake
The technologies of building resists the wind load and earthquakeThe technologies of building resists the wind load and earthquake
The technologies of building resists the wind load and earthquake
 
Devoir d'électricite des bêtiment
Devoir d'électricite des bêtimentDevoir d'électricite des bêtiment
Devoir d'électricite des bêtiment
 
Rapport topographie 2016-2017
Rapport topographie 2016-2017  Rapport topographie 2016-2017
Rapport topographie 2016-2017
 
Case study: Probability and Statistic
Case study: Probability and StatisticCase study: Probability and Statistic
Case study: Probability and Statistic
 
Hydrologie générale
Hydrologie générale Hydrologie générale
Hydrologie générale
 

Kürzlich hochgeladen

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 

Kürzlich hochgeladen (20)

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Travaux Pratique Matlab + Corrige_Smee Kaem Chann

  • 1. 1/3Smee Matlab (TP1) 25%pt 1. Vectors and Matrices Initialize the following variables: A=[ 5 … 5 ⋮ ⋱ ⋮ 5 … 5 ] 9×9 (use ones,zeros) ,B= (A 9x9 matrix of all 0 but with the values [1 2 3 4 5 4 3 2 1] on diagonal, use zeros, diag) C= (A 3x4 matrix, use NaN) ,D= 2. Define the vector V = [0 1 2 ... 39 40]. What is the size of this vector? Define the vector W containing the first five and the last five elements of V then define the vector Z = [0 2 4 ... 38 40] from V. 3. Define the matrix What are its dimensions m x n? Extract from this matrix and .. Make a matrix Q obtained by taking the matrix M intersected between all the 3rd rows and one column out of 2. Calculate the matrix products NP = N x P, NtQ = N 'x Q and NQ = N x Q, then comment the results. 4. Define the variable 𝑥 = [ 𝜋 6 , 𝜋 4 , 𝜋 3 ] and calculate y1=sin(x) and y2=cos(x) Then calculate tan(x) using only the previous y1 and y2. 5. The following vectors are considered: 𝑢 = ( 1 2 3 ) , 𝑣 = ( −5 2 1 ) 𝑎𝑛𝑑 𝑤 = ( −1 −3 7 ) a. Calculate t=u+3v-5w b. Calculate ‖𝑢‖, ‖𝑣‖, ‖𝑤‖ and the cosine of the angle α formed by the vectors u and v, and α in degrees. 6. Application:This problem requires you to generate temperature conversion tables. Use the following equations, which describe the relationships between tempera-tures in degrees Fahrenheit(TF) , degrees Celsius(TC), kelvins( TK ) , and degrees Rankine (TR ) , respectively: 𝑇𝐹 = 𝑇𝑅 − 459.67 𝑜 𝑅, 𝑇𝐹 = 9 5 𝑇𝐶 + 32 𝑜 𝐹, 𝑇𝑅 = 9 5 𝑇𝑘 You will need to rearrange these expressions to solve some of the problems. (a) Generate a table of conversions from Fahrenheit to Kelvin for values from 0°F to 200°F. Allow the user to enter the increments in degrees F between lines. Use disp and fprintf to create a table with a title, column headings, and appropriate spacing. (b) Generate a table of conversions from Celsius to Rankine. Allow the user to enter the starting temperature and the increment between lines. Print 25 lines in the table. Use disp and fprintf to create a table with a title, column headings, and appropriate spacing. (c) Generate a table of conversions from Celsius to Fahrenheit. Allow the user to enter the starting temperature, the increment between lines, and the number of lines for the table. Use disp and fprintf to create a table with a title, column headings, and appropriate spacing. 7. Defined function Write in Matlab to find roots of quadratic equation 𝑦 = 𝑎𝑥2 + 𝑏𝑥 + 𝑐 by contained the roots 𝑥 = [𝑥1 𝑥2]. Now, apply your program for the following cases: a. a=1,b=7,c=12 b. a=1,b=-4,c=4 c. a=1,b=2,c=3 8. Using a function to calculate the volume of liquid (V) in a spherical tank, given the depth of the liquid (h) and the radius (R). V=SphereTank(R,h) Now, apply your program for the following cases: a. R=2,h=1 b. R=h=5 𝑉 = 𝜋ℎ2(3𝑅−ℎ) 3
  • 2. 2/3Smee Solution 1. A=5*ones(9) or A=5.+zeros(5,5) B. a=[1:5,4:-1:1] b=diag(a) c=zeros(9,9) D=b+c or D=diag([1:5,4:-1:1])+zeros(9,9) C=NaN(3,4) D=([1:10;11:20;21:30;31:40;41:50;51:60;61:70;71:80;81:90;91:100])' 2. V=[0:40] size(V) W=[V(:,1:5) V(:,37:41)] Z=V(:,[1:2:40]) 3. M=[1:10;11:20;21:30] size(M) N=M(:,1:2) P=M([1 3],[3 7]) Q=M(:,[1:2:10]) NP=N*P NtQ=N'*Q NQ= %Error because both its size is not available for multiple matric 4. x=[pi/6 pi/4 pi/3] y1=sin(x) y2=cos(x) y=y1./y2 5. u=[1;2;3] v=[-5;2;1] w=[-1;-3;7] t=u+3*v-5*w U=norm(u) V=norm(v) W=norm(w) z=dot(u,v); a=z/[U*V] b=acosd(a) 6. a. incr=input('put the value of the incressing temperature') F=0:incr:200; K=(5.*(F+459.67)./9); table=[F;K]; disp('Conversions from Fahrenheit to kelvin') disp('In_F conversion to Kelvin') fprintf('%3.4f %3.4frn',table); b. S=input('put the value of the starting temperature') C=linspace(S,200,25); R=(C+273.15).*1.8; table=[C;R]; disp('Conversions from C to Rekin')
  • 3. 3/3Smee disp('In_C conversion to Rekin') fprintf('%3.4f %3.4frn',table); c. S=input('put the value of the starting temperature') incr=input('put the value of the incressing temperature') C=linspace(S,200,incr); F=1.8.*C+32 table=[C;F]; disp('Conversions from C to F') disp('In_C conversion to F') fprintf('%3.4f %3.4frn',table); 7. Defined Function function x = quadratic(a,b,c) delta = 4*a*c; denom = 2*a; rootdisc = sqrt(b.^2 - delta); % Square root of the discriminant x1 = (-b + rootdisc)./denom; x2 = (-b - rootdisc)./denom; x = [x1 x2]; end Comment Window quadratic(1,7,12) quadratic(1,-4,4) quadratic(1,2,3) 8. function volume=SphereTank(radius,depth) volume= pi*depth.^2*(3.*radius-depth)/3; end Comment Window SphereTank(2,1) SphereTank(5,5) ______________________________________________________________________________________________________________________ 8/13/2017 5:32PM Corrected by Mr.Smee Kaem Chann Tel : +885965235960