SINGULAR VALUE DECOMPOSITION PROJECT REPORT Submitted by BL.EN.U4AIE20037 N.Preeti BL.EN.U4AIE20019 Hema Srivarshini Chilakala In partial fulfillment for the award of the degree Of BACHELOR OF TECHNOLOGY IN MATHEMATICS FOR INTELLIGENT SYSTEMS - I AMRITA SCHOOL OF ENGINEERING, BANGALORE AMRITA VISHWA VIDYAPEETHAM BANGALORE - 560035 March 2021 INDEX Abstract Introduction Spectral Decomposition Singular value Decomposition(SVD) Application Least Square Method Conclusion Matlab Animation ABSTRACT: The singular value decomposition(SVD) is one of the most highlighted and most important part in Linear Algebra. It has emerged as one of the successful concept of linear algebra , a new method for processing different scenario . The material covered in this paper talks about what is spectral decomposition , what is singular value decomposition(SVD),why is it a highlighted topic in Linear Algebra, discusses the methods that operate on square symmetric matrices such as spectral decomposition, why has it emerged as one of the most used technique for reduction of any kind of data ,what are the various application of SVD,importance in image processing ,importance in Genomics, importance in Data science,how important it is in statistics and how is it the main logical reason behind the success of huge OTT platforms like Netflix,Amazon prime etc. INTRODUCTION : In linear algebra, the singular value decomposition (SVD) is a factorization of a real or complex matrix that generalizes the eigendecomposition of a square normal matrix to any via an extension of the polar decomposition. The SVD is a widely used techniques to decompose a matrix into several individual matrices,exposes many of the properties of the main matrix. Two main operations take place : 1)Rotating 2)Stretching Mainly used to reduce dimensions . SPECTRAL DECOMPOSITION An nxn matrix A can be expressed as the matrix product A=PDPT D is diagonal And P orthogonal matrix . The diagonal entries of D are eigenvalues of A and the columns of P are associated orthonormal eigenvectors. The above expression is called spectral Decomposition of A. We can write it as: The matrix product DPT gives: We can express A as a linear combination of matrices, and the coefficients are the eigenvalues of A. SINGULAR VALUE DECOMPOSITION: SVD is a process in which a matrix is converted into three different matrices.It can be written as follows: A = USVT 1 A is an mxn matrix U is a mxm matrix(orthogonal) S is a mxn diagonal matrix V is a nxn matrix (orthogonal) The following is technical description: We know that matrix U and V are orthogonal , hence they can be written as : UUT = VVT= I Here I is an identity matrix .By using this property of orthogonal matrices , we can rearrange (1) as follows: AAT = US2 2 ATA = VS2 3 Since Transpose(A)A is the same size or smaller than A Transpose(A), a typical procedure is to plug Equation (3) into an eigenvalue calculator to find V and S² and then find U by projecting A onto V: U = AVS-1 4 And A in equation 1 is transposed we get AT = VSUT Thus, if m < n, we can transpose A, perform the decomposition, then swap the roles of U and V. In this case, U will be an m x m square matrix since there can be at most m non-zero singular values, while V will be an n x m matrix. Following is a small example of how SVD is used: Suppose we have two 2Dimensional vectors x1=(x1,y1) and x2=(x2,y2) . We can consider a as major axis and b as minor axis and form the ellipse.But to make things easier we can write the equation in matrix algebra. Let x’=(x’,y’) be the transformed coordinates: X’=XRM-1 Here R is rotation matrix R = cos(α) sin(α) -sin(α) cos(α) M is a diagonal matrix ,it consists of the major and minor axis as their diagonal vectors. M = a 0 0 b Equation for general case is: Therefore, the rotation is clockwise, opposite the usual sense because we are going from the untransformed to the transformed coordinate system rather than the other way around. For the resulting ellipse, the angle will be in the usual, counter-clockwise sense. The equation of circle is as follows : We wish to fit a set of x’s, which we collect as the rows of a matrix, X: The resulting matrix equation is : This is the rearrangement of equation(3). APPLICATIONS : There are various applications of SVD in real life : • SVD is used to approximate a matrix by one of low rank. • It is used in image processing .For example we have an image of 1000x2000 pixels,it requires two billion numbers ,but if the picture can be approximated by some 10 terms of SVD then there will be 10 u’s ,10v’sand 10’s. • It is used in web searches , search engines like google search . • Powerful tool in machine learning and modern data analysis. • Least square problems • Classification of hand written digits. • Singular value decomposition has spread through many branches of science, in particular psychology and sociology, climate and atmospheric science, and astronomy. • It is also extremely useful in machine learning and in both descriptive and predictive statistics. Least Square Problems In real life, there might be times when we want to find a “best-fitting” curve to a set of some given points. For example, people might want to find the relationship between lean body mass of human bodies and their muscle strength or analyze how the housing price changes by years to obtain an estimation of the price in the future. Most of the time, we might not be able to find such a linear equation that can be satisfied by all of those points, so finding a “closest” solution is the best we can do. We call these solution to be the least square solutions. Example: Suppose that we have measured three data points (0,6),(1,0),(2,0), and that our model for these data asserts that the points should lie on a line. Of course, these three points do not actually lie on a single line, but this could be due to errors in our measurement. How do we predict which line they are supposed to lie on? The general equation for a (non-vertical) line is y=Mx+B. If our three data points were to lie on this line, then the following equations would be satisfied: 6=M·0+B 0=M·1+B 0=M·2+B In order to find the best-fit line, we try to solve the above equations in the unknowns M and B. As the three points do not actually lie on a line, there is no actual solution, so instead we compute a least-squares solution. Putting our linear equations into matrix form, we are trying to solve Ax=b for . We solved this least-squares problem in this example: y=−3x+5. CONCLUSION • Started out in the social sciences with intelligence testing • Early intelligence researchers noted that tests given to measure different aspects of intelligence, such as verbal and spatial, were often closely correlated. • SVD is known under many different names : factor analysis , principal component (PC) decomposition and empirical orthogonal function (EOF) analysis. • Singular value decomposition has spread through many branches of science, in particular psychology and sociology, climate and atmospheric science, and astronomy. • It is also extremely useful in machine learning and in both descriptive and predictive statistics. REFERENCES: • https://mathworld.wolfram.com/SingularValueDecomposition.ht ml • https://www.analyticsvidhya.com/blog/2019/08/5-applicationssingular-value-decomposition-svd-data-science/ • https://orion.math.iastate.edu/tathagat/teaching/18_math207/2 07notes-week16.pdf • https://textbooks.math.gatech.edu/ila/least-squares.html ANIMATION OF NAME 1)HEMA SRIVARSHINI CODE: clear all; clc; A=[0;0];B=[0;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[0;20];B=[20;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[20;0];B=[20;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[30;0];B=[30;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[30;0];B=[50;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[30;20];B=[50;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[30;40];B=[50;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[60;0];B=[60;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[60;40];B=[70;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[70;20];B=[80;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[80;40];B=[80;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[90;0];B=[100;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[100;40];B=[110;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[95;20];B=[105;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[140;0];B=[160;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[160;0];B=[160;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[160;20];B=[140;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[140;20];B=[140;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[140;40];B=[160;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[170;0];B=[170;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[170;40];B=[180;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[180;40];B=[180;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[180;20];B=[170;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[170;20];B=[180;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[190;0];B=[190;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[200;40];B=[210;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[210;0];B=[220;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[220;0];B=[230;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[230;40];B=[240;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[225;20];B=[235;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[250;0];B=[250;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[250;40];B=[260;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[260;40];B=[260;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[260;20];B=[250;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[250;20];B=[260;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[270;0];B=[290;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[290;0];B=[290;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[290;20];B=[270;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[270;20];B=[270;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[270;40];B=[290;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[300;0];B=[300;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[320;0];B=[320;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[300;20];B=[320;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[330;0];B=[330;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[340;0];B=[340;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[340;40];B=[350;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[350;0];B=[350;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end A=[360;0];B=[360;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.05); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[100,0]) drawnow end ANIMATED NAME IMAGE: 2) N.PREETI CODE: clear all; clc;clf; %Letter N A=[-35;0];B=[-35;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[-35;40];B=[-10;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[-10;0];B=[-10;45]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %Symbol . A=[-5;20];B=[-5;21]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %Letter P A=[0;0];B=[0;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[0;40];B=[25;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[25;40];B=[25;25]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[25;25];B=[0;25]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B % line equation plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %Letter R A=[30;0];B=[30;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[30;40];B=[55;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[55;40];B=[55;25]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[55;25];B=[30;25]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B % line equation plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[30;25];B=[55;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B % line equation plot(x(1,1),x(2,1),'r.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %letter E A=[60;0];B=[60;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[60;40];B=[85;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[60;20];B=[85;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[60;0];B=[85;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B % line equation plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %letter E A=[90;0];B=[90;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[90;40];B=[115;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[90;20];B=[115;20]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[90;0];B=[115;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B % line equation plot(x(1,1),x(2,1),'y.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %letter T A=[120;40];B=[145;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[132.5;40];B=[132.5;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'g.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end %letter I A=[150;40];B=[175;40]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[162.5;40];B=[162.5;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end A=[150;0];B=[175.5;0]; for lambda=0:0.05:1 x=(1-lambda)*A+lambda*B plot(x(1,1),x(2,1),'b.','MarkerSize',18) pause(0.001); hold on axis('equal') plot([0,0],[0,100]) plot([0,0],[200,0]) drawnow end ANIMATION: