SlideShare a Scribd company logo
1 of 5
ASSIGNMENT – 2

Ques1 : Equation of a straight line : The equation of a line is y = mx+c where m and c are
constants. Compute y-coordinates of a line with m= 0.5 and c=-2 at following x-coordinates
:
   0, 1.5, 3, 4, 5, 7, 9, 10.
Sol :
>> x = [0, 1.5, 3, 4, 5, 7, 9, 10]

x=
 Columns 1 through 7
     0 1.5000 3.0000           4.0000    5.0000   7.0000   9.0000
 Column 8
 10.0000

>> m = 0.5;
>> c = -2;
>> y = m * x + c

y=
 Columns 1 through 7
 -2.0000 -1.2500 -0.5000            0    0.5000   1.5000   2.5000
 Column 8
  3.0000



Ques2: Multiply, Divide and Exponentiate vectors : Create a vector t with 10 elements : 1
to 10. And then calculate the following quantities.

Sol :
(a) X = t * sin(t)
>> t = 1:1:10

t=
     1   2   3     4   5   6    7   8    9   10

>> x = t.*sin(t)

x=
 Columns 1 through 7
  0.8415 1.8186 0.4234 -3.0272 -4.7946 -1.6765               4.5989
 Columns 8 through 10
  7.9149 3.7091 -5.4402
(b) X = (t-1) / (t+1)

x = (t-1) ./ (t+1)

x=
 Columns 1 through 7
     0 0.3333 0.5000 0.6000            0.6667   0.7143   0.7500
 Columns 8 through 10
  0.7778 0.8000 0.8182


(c) X = sin(t2) / (t2)

>> x = sin(t.*t)./(t.*t)

x=

 Columns 1 through 7

  0.8415 -0.1892         0.0458 -0.0180 -0.0053 -0.0275 -0.0195

 Columns 8 through 10

  0.0144 -0.0078 -0.0051


Ques3: Points on a circle : All points with coordinates x = r cosθ and y = r sinθ where r is a
constant, lie on a circle with radius r, i.e. if they satisfy x2 + y2 = r2. Create a column vector
for θ with values 0, π/4 , π/2 , 3 π/4, π and 5 π/4.
Take r = 2 and compute values of x and y. Also check that x and y satisfy the equation of
circle.
Sol :
>> theta = 0:pi/4:5*pi/4

theta =
      0 0.7854 1.5708         2.3562   3.1416   3.9270
>> r = 2;
>> x = r .* cos(theta)

x=
 2.0000      1.4142      0.0000 -1.4142 -2.0000 -1.4142

>> y = r .* sin(theta)

y= 0     1.4142      2.0000   1.4142   0.0000 -1.4142
>> r = (x .* x + y .* y) .^ (1/2)

r= 2       2       2       2       2       2



Ques4 : The geometric Series.
Sol :
(a)
>> n = 0:1:10

n=     0       1       2       3       4       5    6   7    8   9   10

>> r = 0.5

r=

  0.5000

>> x = r .^ n

x=
 Columns 1 through 7
  1.0000 0.5000 0.2500                             0.1250   0.0625   0.0313   0.0156
 Columns 8 through 11
  0.0078 0.0039 0.0020                             0.0010

>> s = sum(x)

s = 1.9990

>> s = 1/(1-r)

s=2


(b)
>> n = 0:1:50;

>> r = 0.5;

>> x = r .^ n;
>> s = sum(x)

s = 2.0000
>> s = 1 /(1-r)

s=2


(c)
>> n = 0:1:100;

>> r = 0.5;
>> x = r .^ n;
>> s = sum(x)

s= 2

>> s = 1 /(1-r)

s=2



Ques5 : Create a vector and a matrix with following commands : v = 0:0.2:12; and M =
[sin(v) ; cos(v)]; Find the sizes of v and M using the size command. Now extract the first 10
elements of each row of the matrix and display them as column vectors.
Sol :
>> v = 0:0.2:12;
>> M = [sin(v) ; cos(v)];
>> size(v)

ans = 1    61

>> size(M)

ans = 2      61

>> M1 = M(1,1:10)

M1 =
 Columns 1 through 7
   0 0.1987 0.3894 0.5646         0.7174   0.8415   0.9320
 Columns 8 through 10
  0.9854 0.9996 0.9738

>> M1'

ans =
0
  0.1987
  0.3894
  0.5646
  0.7174
  0.8415
  0.9320
  0.9854
  0.9996
  0.9738

>> M2 = M(2,1:10)

M2 =
 Columns 1 through 7
  1.0000 0.9801 0.9211 0.8253   0.6967   0.5403   0.3624
 Columns 8 through 10
  0.1700 -0.0292 -0.2272

>> M2'

ans =
  1.0000
   0.9801
   0.9211
   0.8253
   0.6967
   0.5403
   0.3624
   0.1700
  -0.0292
  -0.2272

More Related Content

What's hot

Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
Comuter graphics bresenhams circle drawing algorithm
Comuter graphics bresenhams circle drawing algorithmComuter graphics bresenhams circle drawing algorithm
Comuter graphics bresenhams circle drawing algorithmRachana Marathe
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse2013901097
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsDrishti Bhalla
 
Max and min trig values
Max and min trig valuesMax and min trig values
Max and min trig valuesShaun Wilson
 
Lesson 30: Duality In Linear Programming
Lesson 30: Duality In Linear ProgrammingLesson 30: Duality In Linear Programming
Lesson 30: Duality In Linear Programmingguest463822
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsKetan Jani
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmMahesh Kodituwakku
 
Calcular modulo de_seccion_de_un_perfil
Calcular modulo de_seccion_de_un_perfilCalcular modulo de_seccion_de_un_perfil
Calcular modulo de_seccion_de_un_perfilJunior Olivo Farrera
 
MANSCIE: Simplex Solution
MANSCIE: Simplex SolutionMANSCIE: Simplex Solution
MANSCIE: Simplex SolutionSamantha Abalos
 
Comuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmComuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmRachana Marathe
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivationKumar
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output PrimitivesPrathimaBaliga
 
Solving trig equations higher
Solving trig equations higherSolving trig equations higher
Solving trig equations higherShaun Wilson
 
Bresenham's line algo.
Bresenham's line algo.Bresenham's line algo.
Bresenham's line algo.Mohd Arif
 
Solving trig equations + double angle formulae
Solving trig equations  + double angle formulaeSolving trig equations  + double angle formulae
Solving trig equations + double angle formulaeShaun Wilson
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.Mohd Arif
 

What's hot (20)

Tugas 1 getaran word
Tugas 1 getaran wordTugas 1 getaran word
Tugas 1 getaran word
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algo
 
Comuter graphics bresenhams circle drawing algorithm
Comuter graphics bresenhams circle drawing algorithmComuter graphics bresenhams circle drawing algorithm
Comuter graphics bresenhams circle drawing algorithm
 
Computer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and EllipseComputer Graphic - Lines, Circles and Ellipse
Computer Graphic - Lines, Circles and Ellipse
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 
Max and min trig values
Max and min trig valuesMax and min trig values
Max and min trig values
 
Lesson 30: Duality In Linear Programming
Lesson 30: Duality In Linear ProgrammingLesson 30: Duality In Linear Programming
Lesson 30: Duality In Linear Programming
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Calcular modulo de_seccion_de_un_perfil
Calcular modulo de_seccion_de_un_perfilCalcular modulo de_seccion_de_un_perfil
Calcular modulo de_seccion_de_un_perfil
 
Matlab file
Matlab file Matlab file
Matlab file
 
MANSCIE: Simplex Solution
MANSCIE: Simplex SolutionMANSCIE: Simplex Solution
MANSCIE: Simplex Solution
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
 
Comuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithmComuter graphics ellipse drawing algorithm
Comuter graphics ellipse drawing algorithm
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Solving trig equations higher
Solving trig equations higherSolving trig equations higher
Solving trig equations higher
 
Bresenham's line algo.
Bresenham's line algo.Bresenham's line algo.
Bresenham's line algo.
 
Solving trig equations + double angle formulae
Solving trig equations  + double angle formulaeSolving trig equations  + double angle formulae
Solving trig equations + double angle formulae
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
 

Similar to Matlab

Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3AhsanIrshad8
 
Initial value problems
Initial value problemsInitial value problems
Initial value problemsAli Jan Hasan
 
Amth250 octave matlab some solutions (2)
Amth250 octave matlab some solutions (2)Amth250 octave matlab some solutions (2)
Amth250 octave matlab some solutions (2)asghar123456
 
Department of MathematicsMTL107 Numerical Methods and Com.docx
Department of MathematicsMTL107 Numerical Methods and Com.docxDepartment of MathematicsMTL107 Numerical Methods and Com.docx
Department of MathematicsMTL107 Numerical Methods and Com.docxsalmonpybus
 
Howard, anton calculo i- um novo horizonte - exercicio resolvidos v1
Howard, anton   calculo i- um novo horizonte - exercicio resolvidos v1Howard, anton   calculo i- um novo horizonte - exercicio resolvidos v1
Howard, anton calculo i- um novo horizonte - exercicio resolvidos v1cideni
 
Lesson 12 centroid of an area
Lesson 12 centroid of an areaLesson 12 centroid of an area
Lesson 12 centroid of an areaLawrence De Vera
 
Sistemas de control para ingenieria 3ra edicion norman s. nise sol
Sistemas de control para ingenieria  3ra edicion  norman s. nise solSistemas de control para ingenieria  3ra edicion  norman s. nise sol
Sistemas de control para ingenieria 3ra edicion norman s. nise solNielsy Quiroga
 
Capítulo 04 carga e análise de tensão
Capítulo 04   carga e análise de tensãoCapítulo 04   carga e análise de tensão
Capítulo 04 carga e análise de tensãoJhayson Carvalho
 
trapezoidal rule.pptx
trapezoidal rule.pptxtrapezoidal rule.pptx
trapezoidal rule.pptxSatishKotwal
 
Internal assessment
Internal assessmentInternal assessment
Internal assessmentgokicchi
 
Matlab ch1 (3)
Matlab ch1 (3)Matlab ch1 (3)
Matlab ch1 (3)mohsinggg
 
Review for the Third Midterm of Math 150 B 11242014Probl.docx
Review for the Third Midterm of Math 150 B 11242014Probl.docxReview for the Third Midterm of Math 150 B 11242014Probl.docx
Review for the Third Midterm of Math 150 B 11242014Probl.docxjoellemurphey
 

Similar to Matlab (20)

Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
 
Palm ch1
Palm ch1Palm ch1
Palm ch1
 
Matlab
MatlabMatlab
Matlab
 
Initial value problems
Initial value problemsInitial value problems
Initial value problems
 
Maths 301 key_sem_1_2007_2008
Maths 301 key_sem_1_2007_2008Maths 301 key_sem_1_2007_2008
Maths 301 key_sem_1_2007_2008
 
Calculo integral - Larson
Calculo integral - LarsonCalculo integral - Larson
Calculo integral - Larson
 
Amth250 octave matlab some solutions (2)
Amth250 octave matlab some solutions (2)Amth250 octave matlab some solutions (2)
Amth250 octave matlab some solutions (2)
 
Department of MathematicsMTL107 Numerical Methods and Com.docx
Department of MathematicsMTL107 Numerical Methods and Com.docxDepartment of MathematicsMTL107 Numerical Methods and Com.docx
Department of MathematicsMTL107 Numerical Methods and Com.docx
 
Howard, anton calculo i- um novo horizonte - exercicio resolvidos v1
Howard, anton   calculo i- um novo horizonte - exercicio resolvidos v1Howard, anton   calculo i- um novo horizonte - exercicio resolvidos v1
Howard, anton calculo i- um novo horizonte - exercicio resolvidos v1
 
Lesson 12 centroid of an area
Lesson 12 centroid of an areaLesson 12 centroid of an area
Lesson 12 centroid of an area
 
Sistemas de control para ingenieria 3ra edicion norman s. nise sol
Sistemas de control para ingenieria  3ra edicion  norman s. nise solSistemas de control para ingenieria  3ra edicion  norman s. nise sol
Sistemas de control para ingenieria 3ra edicion norman s. nise sol
 
Capítulo 04 carga e análise de tensão
Capítulo 04   carga e análise de tensãoCapítulo 04   carga e análise de tensão
Capítulo 04 carga e análise de tensão
 
Ch4
Ch4Ch4
Ch4
 
Mat lab day 1
Mat lab day 1Mat lab day 1
Mat lab day 1
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
trapezoidal rule.pptx
trapezoidal rule.pptxtrapezoidal rule.pptx
trapezoidal rule.pptx
 
Struc lecture
Struc lectureStruc lecture
Struc lecture
 
Internal assessment
Internal assessmentInternal assessment
Internal assessment
 
Matlab ch1 (3)
Matlab ch1 (3)Matlab ch1 (3)
Matlab ch1 (3)
 
Review for the Third Midterm of Math 150 B 11242014Probl.docx
Review for the Third Midterm of Math 150 B 11242014Probl.docxReview for the Third Midterm of Math 150 B 11242014Probl.docx
Review for the Third Midterm of Math 150 B 11242014Probl.docx
 

Recently uploaded

Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!Krish109503
 
Minto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptxMinto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptxAwaiskhalid96
 
How Europe Underdeveloped Africa_walter.pdf
How Europe Underdeveloped Africa_walter.pdfHow Europe Underdeveloped Africa_walter.pdf
How Europe Underdeveloped Africa_walter.pdfLorenzo Lemes
 
30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx
2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx
2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docxkfjstone13
 
25042024_First India Newspaper Jaipur.pdf
25042024_First India Newspaper Jaipur.pdf25042024_First India Newspaper Jaipur.pdf
25042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
Vashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call GirlsVashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call GirlsPooja Nehwal
 
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdf29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdf26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdfFIRST INDIA
 
Enjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...
Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...
Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...Axel Bruns
 
2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx
2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx
2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docxkfjstone13
 
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s LeadershipTDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadershipanjanibaddipudi1
 
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docxkfjstone13
 
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxLorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxlorenzodemidio01
 
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptxKAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptxjohnandrewcarlos
 
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...Axel Bruns
 

Recently uploaded (20)

Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!Israel Palestine Conflict, The issue and historical context!
Israel Palestine Conflict, The issue and historical context!
 
Minto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptxMinto-Morley Reforms 1909 (constitution).pptx
Minto-Morley Reforms 1909 (constitution).pptx
 
How Europe Underdeveloped Africa_walter.pdf
How Europe Underdeveloped Africa_walter.pdfHow Europe Underdeveloped Africa_walter.pdf
How Europe Underdeveloped Africa_walter.pdf
 
30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf30042024_First India Newspaper Jaipur.pdf
30042024_First India Newspaper Jaipur.pdf
 
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Indirapuram Escorts >༒8448380779 Escort Service
 
2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx
2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx
2024 02 15 AZ GOP LD4 Gen Meeting Minutes_FINAL_20240228.docx
 
25042024_First India Newspaper Jaipur.pdf
25042024_First India Newspaper Jaipur.pdf25042024_First India Newspaper Jaipur.pdf
25042024_First India Newspaper Jaipur.pdf
 
Vashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call GirlsVashi Escorts, {Pooja 09892124323}, Vashi Call Girls
Vashi Escorts, {Pooja 09892124323}, Vashi Call Girls
 
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 135 Noida Escorts >༒8448380779 Escort Service
 
29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdf29042024_First India Newspaper Jaipur.pdf
29042024_First India Newspaper Jaipur.pdf
 
26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdf26042024_First India Newspaper Jaipur.pdf
26042024_First India Newspaper Jaipur.pdf
 
Enjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Rajokri Delhi >༒8448380779 Escort Service
 
Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...
Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...
Dynamics of Destructive Polarisation in Mainstream and Social Media: The Case...
 
2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx
2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx
2024 03 13 AZ GOP LD4 Gen Meeting Minutes_FINAL.docx
 
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s LeadershipTDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
TDP As the Party of Hope For AP Youth Under N Chandrababu Naidu’s Leadership
 
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
2024 04 03 AZ GOP LD4 Gen Meeting Minutes FINAL.docx
 
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Iffco Chowk Gurgaon >༒8448380779 Escort Service
 
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptxLorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
Lorenzo D'Emidio_Lavoro sullaNorth Korea .pptx
 
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptxKAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
KAHULUGAN AT KAHALAGAHAN NG GAWAING PANSIBIKO.pptx
 
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
AI as Research Assistant: Upscaling Content Analysis to Identify Patterns of ...
 

Matlab

  • 1. ASSIGNMENT – 2 Ques1 : Equation of a straight line : The equation of a line is y = mx+c where m and c are constants. Compute y-coordinates of a line with m= 0.5 and c=-2 at following x-coordinates : 0, 1.5, 3, 4, 5, 7, 9, 10. Sol : >> x = [0, 1.5, 3, 4, 5, 7, 9, 10] x= Columns 1 through 7 0 1.5000 3.0000 4.0000 5.0000 7.0000 9.0000 Column 8 10.0000 >> m = 0.5; >> c = -2; >> y = m * x + c y= Columns 1 through 7 -2.0000 -1.2500 -0.5000 0 0.5000 1.5000 2.5000 Column 8 3.0000 Ques2: Multiply, Divide and Exponentiate vectors : Create a vector t with 10 elements : 1 to 10. And then calculate the following quantities. Sol : (a) X = t * sin(t) >> t = 1:1:10 t= 1 2 3 4 5 6 7 8 9 10 >> x = t.*sin(t) x= Columns 1 through 7 0.8415 1.8186 0.4234 -3.0272 -4.7946 -1.6765 4.5989 Columns 8 through 10 7.9149 3.7091 -5.4402
  • 2. (b) X = (t-1) / (t+1) x = (t-1) ./ (t+1) x= Columns 1 through 7 0 0.3333 0.5000 0.6000 0.6667 0.7143 0.7500 Columns 8 through 10 0.7778 0.8000 0.8182 (c) X = sin(t2) / (t2) >> x = sin(t.*t)./(t.*t) x= Columns 1 through 7 0.8415 -0.1892 0.0458 -0.0180 -0.0053 -0.0275 -0.0195 Columns 8 through 10 0.0144 -0.0078 -0.0051 Ques3: Points on a circle : All points with coordinates x = r cosθ and y = r sinθ where r is a constant, lie on a circle with radius r, i.e. if they satisfy x2 + y2 = r2. Create a column vector for θ with values 0, π/4 , π/2 , 3 π/4, π and 5 π/4. Take r = 2 and compute values of x and y. Also check that x and y satisfy the equation of circle. Sol : >> theta = 0:pi/4:5*pi/4 theta = 0 0.7854 1.5708 2.3562 3.1416 3.9270 >> r = 2; >> x = r .* cos(theta) x= 2.0000 1.4142 0.0000 -1.4142 -2.0000 -1.4142 >> y = r .* sin(theta) y= 0 1.4142 2.0000 1.4142 0.0000 -1.4142
  • 3. >> r = (x .* x + y .* y) .^ (1/2) r= 2 2 2 2 2 2 Ques4 : The geometric Series. Sol : (a) >> n = 0:1:10 n= 0 1 2 3 4 5 6 7 8 9 10 >> r = 0.5 r= 0.5000 >> x = r .^ n x= Columns 1 through 7 1.0000 0.5000 0.2500 0.1250 0.0625 0.0313 0.0156 Columns 8 through 11 0.0078 0.0039 0.0020 0.0010 >> s = sum(x) s = 1.9990 >> s = 1/(1-r) s=2 (b) >> n = 0:1:50; >> r = 0.5; >> x = r .^ n; >> s = sum(x) s = 2.0000
  • 4. >> s = 1 /(1-r) s=2 (c) >> n = 0:1:100; >> r = 0.5; >> x = r .^ n; >> s = sum(x) s= 2 >> s = 1 /(1-r) s=2 Ques5 : Create a vector and a matrix with following commands : v = 0:0.2:12; and M = [sin(v) ; cos(v)]; Find the sizes of v and M using the size command. Now extract the first 10 elements of each row of the matrix and display them as column vectors. Sol : >> v = 0:0.2:12; >> M = [sin(v) ; cos(v)]; >> size(v) ans = 1 61 >> size(M) ans = 2 61 >> M1 = M(1,1:10) M1 = Columns 1 through 7 0 0.1987 0.3894 0.5646 0.7174 0.8415 0.9320 Columns 8 through 10 0.9854 0.9996 0.9738 >> M1' ans =
  • 5. 0 0.1987 0.3894 0.5646 0.7174 0.8415 0.9320 0.9854 0.9996 0.9738 >> M2 = M(2,1:10) M2 = Columns 1 through 7 1.0000 0.9801 0.9211 0.8253 0.6967 0.5403 0.3624 Columns 8 through 10 0.1700 -0.0292 -0.2272 >> M2' ans = 1.0000 0.9801 0.9211 0.8253 0.6967 0.5403 0.3624 0.1700 -0.0292 -0.2272