Part B - Write your own MATLAB Functions & Sub-functions Function purpose: You are working in the lab on an experiment where you are gathering a lot of data. You want to use MATLAB to collect and...


Part B - Write your own MATLAB Functions & Sub-functions<br>Function purpose: You are working in the lab on an experiment where you are gathering a lot of data.<br>You want to use MATLAB to collect and analyze the data. As you are conducting the experiment, you<br>want MATLAB to prompt you to enter the data for each trial. Once you finish collecting, you want<br>MATLAB to automatically calculate some important metrics.<br>1. Create a MATLAB function called enter_data.m. The function will take in a single input,<br>which is the number of experimental trials. The function should then prompt the user to:<br>a. enter the name of the trial (character array, EX: 'test 1')<br>b. first measurement (double floating point, EX: 3.567)<br>c. second measurement (double floating point, EX: 3.337)<br>d. third measurement (double floating point, EX: 3.110)<br>e. Each of these fields should then be an element in a row of a cell array. Your function<br>should return a single variable, which is a cell array that contains all the information about<br>all the data entered, each trial's information should be on a separate row.<br>2. Create a second MATLAB function called calc_stats.m that can receive the data from part 1<br>above as an input. Then, it creates two outputs:<br>a. A single array that contains the averages (across all trials) for each of the three<br>measurements. This array will always be 3 elements big.<br>b. A single array that contains a calculated metric based on the weighted sum of all three<br>measurements. For each trial you will calculate:<br>m=0.2*m1+0.2*m2+0.4*m3<br>where ml is the first measurement, m2 is the second measurement, and m3 is the third<br>measurement. You can choose to do the calculation in a loop or using vectorized notation.<br>**For both of these calculations, you will need use the {} notation to access the values of<br>the cell array.<br>3. Create a third MATLAB function called L2_b_Section#_Lastname_Firstname.m'. There will be<br>no inputs and no outputs to this main function. The first line of code should be to call your<br>enter_data function, the input should be 2 trials and average the output array as data2. The<br>second line of code should be to call your calc_stats function with data2 as the input. Save<br>the two outputted arrays to two new variables. Display the final metrics to the screen in a useful<br>way.<br>

Extracted text: Part B - Write your own MATLAB Functions & Sub-functions Function purpose: You are working in the lab on an experiment where you are gathering a lot of data. You want to use MATLAB to collect and analyze the data. As you are conducting the experiment, you want MATLAB to prompt you to enter the data for each trial. Once you finish collecting, you want MATLAB to automatically calculate some important metrics. 1. Create a MATLAB function called enter_data.m. The function will take in a single input, which is the number of experimental trials. The function should then prompt the user to: a. enter the name of the trial (character array, EX: 'test 1') b. first measurement (double floating point, EX: 3.567) c. second measurement (double floating point, EX: 3.337) d. third measurement (double floating point, EX: 3.110) e. Each of these fields should then be an element in a row of a cell array. Your function should return a single variable, which is a cell array that contains all the information about all the data entered, each trial's information should be on a separate row. 2. Create a second MATLAB function called calc_stats.m that can receive the data from part 1 above as an input. Then, it creates two outputs: a. A single array that contains the averages (across all trials) for each of the three measurements. This array will always be 3 elements big. b. A single array that contains a calculated metric based on the weighted sum of all three measurements. For each trial you will calculate: m=0.2*m1+0.2*m2+0.4*m3 where ml is the first measurement, m2 is the second measurement, and m3 is the third measurement. You can choose to do the calculation in a loop or using vectorized notation. **For both of these calculations, you will need use the {} notation to access the values of the cell array. 3. Create a third MATLAB function called L2_b_Section#_Lastname_Firstname.m'. There will be no inputs and no outputs to this main function. The first line of code should be to call your enter_data function, the input should be 2 trials and average the output array as data2. The second line of code should be to call your calc_stats function with data2 as the input. Save the two outputted arrays to two new variables. Display the final metrics to the screen in a useful way.
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here