Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CIVE 3066: Engineering systems and decision analysis Fall 2016 (55NKN) Solution LAB 1: Introduction to the MATLAB environment Exercice 1: Create x is a row vector containing 10 double random numbers whose value is between 3 and 10. x=3 + (10-3)*rand(1,10,’double’); Exercice 2: Create the following matrices: A is a matrix with 2 rows and 3 three columns containing double random numbers whose value is between 10 and 15. A=10 + (15-10)*rand(2,3,’double’); B is a diagonal matrix of size 2x2 with the random value in the principal diagonal. % V is a vector containing 2 random values V=rand(1,2); % B is the diagonal matrix with the random values of V in the principal diagonal B=diag(V); C is a matrix of size 5x5 with the random values in the second diagonal % V is a vector containing 5 random values V=rand(1,5); % C is the diagonal matrix with the random values of V in the principal diagonal C=diag(V); % inverse the column of C so that the values in the principal diagonal are moved to the second diagonal C=C(:,end:-1:1); D is a matrix with 7 rows and 5 columns which is created by concatenating the matrices A and B in the two first rows and the matrix C in the five last row as the following matrix (A(i,j) represent the value of the matrices A at row i and column j, and so on): A(1,1) A(1,2) A(1,3) B(1,1) B(1,2) A(2,1) A(2,2) A(2,3) B(2,1) B(2,2) C(1,1) C(1,2) C(1,3) C(1,4) C(1,5) C(2,1) C(2,2) C(2,3) C(2,4) C(2,5) C(3,1) C(3,2) C(3,3) C(3,4) C(3,5) C(4,1) C(4,2) C(4,3) C(4,4) C(4,5) C(5,1) C(5,2) C(5,3) C(5,4) C(5,5) D=[A B; C]; E is a sub matrix of size 6x2 which takes the values in the rows from 1 to 3 and from 5 to 7 and in the columns 2 and 4 of the matrix D. E=D([1:3 5:7], [2 4]); Exercise 3: Create a vector x of 10 abscissa values linearly spaced between 0 and Pi. 1 CIVE 3066: Engineering systems and decision analysis Fall 2016 (55NKN) x=linspace(0, pi,10); Create three vectors of the values taken by the functions sinus, arctangent and square on the values of the abscissa vector. y1=sin(x); y2=atan(x); y3=x.^2; Plot the curves of functions sinus, arctangent and square between 0 and Pi. p=plot(x,y1,x,y2,x,y3) Improve the previous plot by adding the title “Plot of sin, square and arctangent functions by your name”. (put your name in the title (VD: Nguyen Van A)) title 'Plot of sin, square and arctangent function by Nguyen Van A'; Add a label for the abscissa ‘x’ and for the ordinate ‘y’ xlabel 'x'; ylabel 'y'; Use ‘*’ markers and solid line for the curve of the square set(p(3),'LineStyle' , '-', 'Marker', '*'); Use a dashed line style for the curve of the arctangent set(p(2),'LineStyle' , '--'); Use dotted line, magenta color and square markers for the curve of the sinus set(p(1),'LineStyle' , ':', 'Color', 'm', 'Marker', 's'); Add legend for the three curves above legend('sin(x)','atan(x)','x^2'); Limit the plot to the ordinates between 0 and 6 for y and 0 to pi for x. axis([0 pi 0 6]); 2