Investigating Matlab GUI and Help Functions
The content guides you through exploring the Matlab GUI to check workspace variables, current directory files, and recent commands. It also delves into utilizing Matlab's help to find functions for standard deviation and variance, applying them to a matrix, and performing various mathematical operations using Matlab commands. Additionally, it covers creating vectors, manipulating matrices, and testing expressions with different mathematical functions.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Exercises Investigate the Matlab GUI and make sure you know where the different parts can be found. For example, using the GUI: What (if any) variables are currently in your workspace? What files are in your current directory? What was your last but one command? Use the commands length and size to check your variables Investigate the help available in matlab. Using the help: Find the function for standard deviation. Find the function for variance. Read the help on the standard deviation and variance functions Apply these two functions to the matrix a=[1:10] Do you get 3.0277 and 9.1667?
Create a row vector from 0 to 27 with intervals of 3 Create a column vector with the same contents What are the remainders after dividing this vector by 2? Create a row vector of the even integers between 8 and 12 inclusive Create the first 11 perfect squares Create a column vector with the elements from 100 to 0 Create a row vector with the odd numbers between 0 and 50 source: HKA & AB slides
Let x = [2 5 1 6]. a. Add 16 to each element b. Add 3 to just the odd-index elements c. Compute the square root of each element d. Compute the square of each element Create a vector of the powers of 2 up to 256 Find the cube root of 8 (order of operations: MDAS) e to the power of 3 (use help to find the right function) 3cos( ), sin([0, /4, /2, 3 /4, ]) natural logarithm of 20.0855 and logarithm of 1000
Let x = [3 1 5 7 9 2 6]. For each of the following commands first think about what the result should be and then type the command and verify your answer. a. x(3) b. x(1:7) c. x(1:end) d. x(1:end-1) e. x(6:-2:1) f. x([1 6 2 1 1]) g. sum(x)
Given a vector t, write down the MATLAB expressions that will correctly compute the following: a. ln(2 + t + t2) b. et(1 + cos(3t)) c. cos2(t) + sin2(t) d. tan-1(t) (this is the inverse tangent function) e. cot(t) f. sec2(t) + cot(t) - 1 Test that your solution works for t = 1:0.2:2
1) Enter the following matrices and vectors a = [9 12 13 0; 10 3 6 15; 2 5 10 3] and b = [1 4 2 11; 9 8 16 7; 12 5 0 3] 2) use a and b to create these matrices a) c is the element in the 3rd row and 3rd column of a b) d is column 3 of a c) e is rows 1 and 3 of b d) f is a and b one above each other e) g is column 1 of a next to column 4 of b 3) Change some of the entries in this matrices a) make element (2,2) of e be 20 b) make row 1 of a be all zeros c) make column 3 of f be the numbers from one to 6 d) make column 1 of a be the number from column 2 of b
Given the array A = [ 2 4 1 ; 6 7 2 ; 3 5 9], provide the commands needed to a. assign the first row of A to a vector called x1 b. assign the last 2 rows of A to an array called y c. compute the sum over the columns of A d. compute the sum over the rows of A
A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1] sum (A) sum the transpose of A sum the elements on the main diagonal (address the elements directly or use the diag command) help magic Create a matrix A that increases in steps of 1 from 3 up to 107 Create a matrix B that decreases in steps of 0.5 from 333 down to -10 Create a 2d matrix called C of size 100 rows by 100 columns containing only the number 1 Create a 2d matrix called C of size 100 rows by 200 columns containing only the number 4 Try defining: D = [ 1, 2, 3, 4; 5 6 7 ] What did I do wrong? If I define E = [ 10:1 ] what would you expect E to be? Try it. Can you understand what has happened?
Let x = [3 2 6 8] and y = [4 1 3 5] (Note that x and y are row vectors) b. Raise each element of x to the power specified by the corresponding element in y. c. Divide each element of y by the corresponding element in x d. Multiply each element in x by the corresponding element in y, calling the result "z". e. Add up the elements in z and assign the result to a variable called "w". f. Compute x*y' - w and interpret the result
Create a matrix m that contains two rows of data. The top row are the numbers 4, 5 and 6 and the bottom row 9, 6 and 3. Create a matrix n that contains two columns of data. The 1st column are the numbers 1, 3, 5 and 7 and the 2nd column are 2, 4, 6 and 8. What is: (1) m.^2 (2) n.^2 (3) n*m (4) m'*n Create a vector x with 100 elements where component xnis xn= ( 1)n+1/ (2n-1), n=1 to 100 Sum up all the elements of this vector.
1) Enter the following matrices and vectors: A = [1 5 6; 3 0 8], B = [7 3 5; 2 8 1], C = 10 and D = 2 2) Do these sums: E = A B, F = D*B, G = A.*B, H = A , J = B/D 3) Do some maths on parts of matrices a) Put the first column of A into M b) Put the second column of G into N c) Add them together d) Multiple ONLY the third column of A by C and put the result back in the third column of A. You can use several steps if you want, but it is possible do use just one line. e) Find the Dth row of H (i.e. row 2) and sum all the elements in that row f) Create a new matrix K made up of A in the first 2 rows and B in the next 2 rows. 4) Find the maximum values of each column of J, and find the minimum value of each row of B
1. Create a row vector v with values (1, 2, 3, 5, 11, 7, 13). 2. Change the value of the 5th and the 6th element of v to 7 and 11 respectively. Try doing this with only one command as well. 3. Create a vector Five5 out of all multiples of 5 that fall between 34 and 637. By the way, how many are they? (Tip: look up the command length in help.) 4. Double click on the variable Five5 in the Workspace to inspect your results in the Variable Editor. 5. Can you use the colon operator to extract the numbers in the vector Five5 that are multiples of 5 only but not 10 ? 6. Create a random vector with 100 random integers between 0 and 100. Find the minimum value, the maximum value, the mean and the standard deviation using some of the built-in functions