## 3. Matlab Programming (3.5 points) Scripts simplify things, but you can make scr

3. Matlab Programming (3.5 points) Scripts simplify things, but you can make scripts powerful using programming concepts such as conditional statements. For example: If statement if . . . etc. elseif . . . etc. elseif . . . etc. else . . . etc. end Here, if is true, only will be executed. if the condition was false, then Matlab check for . If is true, only will be executed, and so on. If none of the conditions are true, then only will be executed. (Type help if for more variations on the use of if statement). For loop for loop_index = min_value: increment : max_value end Here, the loop index is started with a value equal to min_value, and increased with the increment value until the index value is equal max_value. The loop is executed after every index increment. MAE 211 Mechatronics Spring 2018 Page 4 of 4 While loop while end Here, Matlab will check the condition and execute the if the is true. After each execution, Matlab checks the condition again. a. For all the integers between 0 and 1000, find the list of numbers where the result of dividing the number by the sum of its digits is an integer. You should be using if condition, for loop, and while loop. Example 24 should be in your list because (24/(2+4) = 4). You should store the list of numbers in a vector. b. Write your own version of Matlab code for multiplying two given matrices. You should check the matrices sizes to ensure the product is defined. c. Create 20 rows and 30 columns matrix using Matlab rand function. Iterate over the matrix elements, and set the element to 0 if its value less than 0.5, and set the element to 1 otherwise. 4. Creating Functions (2 points) Matlab has some built-in functions that we have already used, such as sin(x), plot, etc. Type help function and read the documentation and examples on how to create functions in Matlab. Create a function called custom_matrix.m that take two parameters, the matrix number of rows (i) and columns (j). The output of your function should be a matrix called SM. The elements of SM(m,n) where m == n should be (m*n). The elements of SM(m,n) where m > n should be (m). The elements of SM(m,n) where n > m should be n. An example of your function output when i=4 and j = 4 is provided below. [ 1 2 3 4 2 4 3 4 3 3 9 4 4 4 4 16]