Part A : Creating and Manipulate the Matrix in MATLAB
1
3)
and 2
a)
b)
c)
d)
4. Creating Matrix A
a)
b)
c)
d)
i)
ii)
iii)
e)
f)
g)
h)
i)
PART B : x-y Cartesian Plots in MATLAB
2. a)
B)
c)
PART C : Simulink
DISCUSSION
From the lab work 4 MatLab for Engineering Application on Matrix
Operations, Graph Plotting and Simulink we had used the Matlab 7.1 software to perform matrix operation, Graph plotting and Simulink. The basic element in MATLAB is the matrix. In its simplest form a matrix is a set of numbers or elements arranged in a rectangular grid of horizontal rows and vertical columns. Every row or column in a matrix is also called a vector. An array with m rows and n columns is referred as an m times n matrix, denoted by m n indicating the size or the matrix dimension, consisting of a total number of m*n elements. In part A we had created and manipulated the matrix in MATLAB where we had created the matrix by typing each elements of a row, row by row, with a space separating the elements in that row. Then, we also had used semicolons to separate the rows of the matrix and to form the columns of the matrix. The increment is done by using the colon : where is should be written as (initial value : increment value : final value). Besides that, the input statement also can be used to enter a string with or without the argument s present and with or without quotes . Then, matrix command such as space, comma , for rows and semicolon ; were used to perform a 3 by 3 matrix. With the matrix that have been created the size of the matrix, row and column size, length of the matrix and the elements in the matrix can be found by using some specific command such as size ( A), [row,col] = size( A ), length (A) and A(n,m) respectively. Colons when used as an argument identify a range over a row or a column depending on its location and when a matrix index is replaced by a colon, the colon represents depending on its location, either all the rows or all the columns. The colon in front of the commands displays the row whereas if the colon is placed behind the commands will display the columns. For square values of each elements it should written as the A.^2 where A is the matrix and each of its value squared. Finally, to find the sum and products for the matrices such as n=(1: 5) it should written as sum(n) where it return the sum of the entire column of the matrix n and prod(n) where it will return the product of the entire column of the matrix n In part B we had created x-y Cartesian plots in MATLAB. We had used the command plot (x,y) to plot the graph for vectors. We also have used the fplot command to create some graph. The difference between plot and fplot is the fplot graph will be smooth compared to the constructed using just plot. Besides that we have applied all the commands that we have learnt in pervious part and labs when doing this part such colon where it is used for increment, * for multiplication and many more. We also constructed two graph together and changed the colour and marks for the both graph so it can be differentiated. Finally, once we had created the graph we had use some commands to show the legend, box, grid, xlabel, ylabel, adjust text size and write the title for the graph that have been constructed.
In part C we had executed the simulink design where we had used
the simulink library to construct the DC motor with shaft velocity as the output design. We had plotted a graph for the executed simulink and showed grid, xlabel, ylabel, adjust text size and write the title for the graph that have been constructed. While performing this lab work we had experienced some error such as typing error. We had faced this error when we was typing the command. Besides that, we also faced some error due to wrong selection of the elements from the simulink library. We had overcome these errors by repeating and retyping the command until we get the correct result. Ours lecturers also helped us to indentify our errors and how to solve it. Through this, we have experience on how to encounter the same error again after this.