Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CS240 INTRO TO ENGINEERING PROGRAMMING, Spring 2021 MATLAB Programming Assignment 05 Due, Friday 54 March by midnight Topics: Matrices, built-in functions, find function, user function,
CS240 INTRO TO ENGINEERING PROGRAMMING, Spring 2021 MATLAB Programming Assignment 05 Due, Friday 54 March by midnight Topics: Matrices, built-in functions, find function, user function, input prompt 1. Programos.m 1) Create a MATLAB Program titled Programos. m and open the file. 2) Call myPrompt function and store the retumed array in retArt, if it is empty then end the program, 3) Call Matrix Generator function and store the returned array in my Mat, if it is empty then end the program 4) Call Fix_my Mat function and store the returned array in new Mat, if it is empty then end the program 5) Merge sorted myMAT and sorted newMAT arrays in two rows, store it in comp_Mat. 6) Print comp_Mat shown in the Sample Run. 2. myPrompt.m - Create a MATLAB Program titled myPrompt.m and open the file. Setup a retum value called retArr, no need for input arguments. - Prompt the user to input the following: (1) Start limit of the range of numbers to generate matrix, store it in a local variable called min_bound. (mist he henveen -10 and (1) (ii) End limit of the range of numbers to generate matrix, store it in a local variable called max_bound. (must be between / and 50) (iii) No. of rows for the matrix, store it in a local variable called rows. (nusi be 1) (iv) No. of columns for the matrix, store it in a local variable called cols. (miast he between 1 and 40) Merge ALL the entered values in a 1x4 array, store it in the output argument retArr. - Validate ALL the user inputs, if any of the entered numbers is out of range, display an crror message on the command window and sct retArr to an empty array. 3. Matrix Generator.m Create a MATLAB Program titled Matrix Generator m and open the file. - Setup one output argument; call it myMAT, and four input arguments, min_bound, max_bound, rows, cols. Sel seed number to (7) Ciencrate a uniformod random array using rand function using the input arguments, store it in myMAT Validate myMAT array, if the number of rows or number of columns is different than the input arguments, display an error message (Invalid my MAT dimensions) on the command window and set myMAT to an empty array. Validate myMAT array, if the minimum number is lower than min_bound or the maximum number is higher than max_bound, display an error message (Invalid myMAT boundaries) on the command window and set myMAT to an empty array. Sample Run 2: Enter min. bound (between-10 and O): 5 Enter max. bound (between 1 and 50): 20 Enter number of rows (must be l): 1 ): 1 Enter number of cols (between 1 and 40): 40 Invalid min_bound !! 4. Fix_myMat.m Create a MATLAB Program titled Fix_myMAT.m and open the file. Sctup one input argumcnt; call it mat, and one output argumcnt; call it new_mat. Extract all negative numbers from mat array, store them in a local variable called neg_num, round all numbers to the ncarest highest whole number. - Extract all numbers between 15 and 25 from mat array, store them in another local variable called range_num, round all numbers to the nearest lowest whole number, - Extract all positive numbers those who are less than 15 or greater than 25 from mat array, store them in a third local variable called round_num, round all numbers to a whole number Merge ALL three local variables in a 1x4 array in the order of neg_num then range_num then round num, store it in the output argument new_mat. - Validate the number of elements and the size of new_mat array, if they are different than the number of elements and the size of the original mat array, then display an error message (Invalid new_mar dimensions) on the command window and set new_mat to empty array. Sample Run 3: Enter min. bound between 10 und 0): -5 Enter max. bound (between 1 and 50): 0 Enter number of rows (must be 1): 1 Enter number of cols (between 1 and 40): 20 Invalid max bound !! Upload ALL the four m-files script files on CANVAS. Sample Run 4: Enter min. bound between -10 and 0): -5 Enter max. bound (between 1 and 50): 50 Enter number of rows (must be 1): 1 ): 1 Enter number of cols (between 1 and 40): 40 -3.6305 -1.3735 - 1 Sample Run 1: Enter min. bound (between 10 and 0): 4 Enter max. bound (between 1 and 50): 30 Enter number of row's (must be 1): 2 Enter number of cols (between 1 and 40): 20 Invalid rows !! -1.0372 -0.8030) 0 2.3243 2 6.2667 6 6.7362 7 7.6667 45.0021 45 10 45 9.7641 10.1827 45.0276 46.2163 10 46 10.8480 11 47 47.2571 48.7894 12.2697 12 49 15.1240 15 15.4812 15 15.9518 15 19.1125 19 19.8668 19 20.7264 20 21.2571 21 21.9921 21 22.4935 22 22.5616 22 23 23.7877 24.6173 25.1669 25 26.4944 26 28.0302 28 32 31.7957 32.3576 32 34.7906 35 36.2725 36 37.2756 37 37.8955 38 39.2056 39 41.0855 41
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started