Worksheet 8

doc

School

Boston University *

*We aren’t endorsed by this school

Course

101

Subject

Mechanical Engineering

Date

Feb 20, 2024

Type

doc

Pages

2

Uploaded by KidRiver13416

Report
ENG EK 125 Worksheet 8 Name: __________________________________________________ The minimum set is Problems 1-4. 1) Create a cell array variable that would store for a student their name, university id number, and GPA. Print this information. myinfo = { 'name' , 'Jeet' , 'Uni ID' , 'U00204914' , 'GPA' , '4.0' } fprintf(1, '%s ' , myinfo{:}) 2) Create a structure variable that would store for a student their name, university id number, and GPA. Print this information. persoinfo = struct( 'name' , 'Jeet' , 'UniID' , 'U00204914' , 'GPA' , '4.0' ); disp(persoinfo)
3) Create a data structure to store information about the elements in the periodic table of elements. For every element, store the name, atomic number, chemical symbol, class, atomic weight, and a 7-element vector for the number of electrons in each shell. Create a structure variable to store the information, for example for lithium: Lithium 3 Li alkali_metal 6.94 2 1 0 0 0 0 0 4) A team of engineers is designing a bridge to span the Podunk River. As part of the design process, the local flooding data must be analyzed. The following information on each storm that has been recorded in the last 40 years is stored in a file: a code for the location of the source of the data, the amount of rainfall (in inches), and the duration of the storm (in hours), in that order. For example, the file might look like this: 321 2.4 1.5 111 3.3 12.1 etc. Create a data file. Write the first part of the program: design a data structure to store the storm data from the file, and also the intensity of each storm. The intensity is the rainfall amount divided by the duration. Write a function to read the data from the file (use load ), copy from the matrix into a vector of structs, and then calculate the intensities. Write another function to print all of the information in a neatly organized table. Add a function to the program to calculate the average intensity of the storms. Add a function to the program to print all of the information given on the most intense storm. Use a local function for this function that will return the index of the most intense storm . 5) Create a vector of structures experiments that stores information on subjects used in an experiment. Each struct has four fields: num , name , weights , and height . The field num is an integer, name is a string, weights is a vector with two values (both of which are double values), and height is a struct with fields feet and inches (both of which are integers). The following is an example of what the format might look like. experiments num name weights height 1 2 feet inches 1 33 Joe 200.34 202.45 5 6 2 11 Sally 111.45 111.11 7 2 Write a function printhts that will receive a vector in this format and will print the name and height of each subject in inches (1 foot = 12 inches). This function calls another function howhigh that receives a height struct and returns the total height in inches. This function could also be called separately.
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