BMEN 3311 Lab 1 F2023

docx

School

University of North Texas *

*We aren’t endorsed by this school

Course

3311

Subject

Computer Science

Date

Dec 6, 2023

Type

docx

Pages

6

Uploaded by UltraGoldfish3847

Report
BMEN 3311 Lab 1 – Basics of MATLAB Names: ID: Make sure all questions are answered, lab report is properly formatted/easy to read, names student ID are typed, screenshots are all visible and legible, and submitted before deadline. Practice 1 – Variables – 10 points Write a command to clear the MATLAB workspace. Then, create the following variables: 1. A variable called a which has the character value ‘q’. 2. A variable called b which has the Boolean value true. 3. A variable called c which is an array of integers between 1 and 10. 4. A variable called d which is an array of characters with the values ‘h’, ‘e’, ‘l’, ‘l’, ‘o’. Now find out the data types of all variables you just created. Label them as comments in MATLAB. Ex. variable = false; %Boolean Submit as script or screenshot below. Make sure the code runs correctly for all problems.
Practice 2 – Array Operation – 10 points Let a = [1 3 1 2] and b = [7 10 3 11]. Run commands sequentially. 1. Sum all elements in a and add the result to each element of b. 2. Raise each element of b to the power of the corresponding element of a. hint: (array b)^(array a) 3. Divide each element of b by 4. 4. Display b (final result)
Practice 3 – function and save – 15 points Write MATLAB commands to compute the sine , cosine and tangent of an array of numbers between 0 and 2 π (in steps of 0.1). Save the original input array (using the save function) and all three output arrays to a single MAT file (named trig.mat ) and then clear the workspace.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Practice 4 – math – 15 points Write a MATLAB script that reads in three floating point values from the user (a, b and c), which represent the lengths of three sides of a triangle. Then compute the area of the triangle according to the equation: where s is half of the sum of the three sides, or the average of a, b, & c. Hint: look up MATLAB function that prompts read-in values from user
Practice 5 – Heart rate calculation – 40 points A PPG signal is modeled using the following equation: y = f ( t )= 6.8 sin ( 2 π 1 t ) + 4.4 sin ( 2 π 2 t ) 1. In MATLAB, create a plot of the modeled PPG waveform. Assume that each data point is 1 ms apart, and create a signal 3 seconds in length. Label the plot “Modeled PPG”, y-axis “Magnitude”, and x-axis “Time(s)”. 2. What is the maximum amplitude of the modeled signal? 3. Use the function findpeaks to help determine the instantaneous heart rate in beats per minute of the modeled signal with following equation. HR = 60 ( T 2 T 1 ) Hint: Set up the function to return the magnitude and location of peaks. For example [y x] = findpeaks(signal). Heat Rate = ______ BPM
Practice 6 – load and plot ECG data – (bonus 20 points). An ECG (ecg_100.dat) data has 2 channels, recorded as 360Hz, and total length is 10 seconds. The ECG device has a maximum recording range of 0-10mV and sampled at 12bits. Write a code to load and plot this data. Specific note: this is one type of very common biosignal raw data. The data is always saved as binary format with a specific bit precision. The raw data is also arranged as the single-line long format as: Sample1_channel1 Sample1_channel2 Sample2_channel1 Sample2_channel2 Sample3_channel1 Sample3_channel2 … … Two hints here to help you get through the coding: 1, for loading the 12bit unsigned data, use the precision ‘ubit12’. The unsigned 12bit data is ranged from 0 to 2^12, you need to assign them to 0-10 mV. 2, the channel 1 in the single-line long format should be read by 1:2:length(data).
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help