Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 3: Cell Arrays & Structures (Individual work) From: MATLAB: A Practical Introduction to Programming and Problem Solving 3rd Edition, Stormy Attaway, Butterworth-Heineman (2013) 1.
Part 3: Cell Arrays & Structures (Individual work) From: MATLAB: A Practical Introduction to Programming and Problem Solving 3rd Edition, Stormy Attaway, Butterworth-Heineman (2013) 1. Create three cell array variables that stores names, verbs, and nouns. For example: names{'Harry', 'Zavier', 'Sue', 'Alexis', 'Harvey'; verbs('loves 'eats', studies'}; nouns {'baseballs', 'rocks', 'sushi', 'computers'); write a script named Wagnexethat will initialize these cell arrays and then prints sentences using one random element from each cell array (e.g., 'Xavier eats sushi') Hint: MATLAB's candi function generates a random integer number between given bounds. 2. Write a function convstrs that will receive a cell array of strings and a character (either 'U' or 'L') as input arguments. If the character is 'U', it will return a new cell array with all of the strings in uppercase. If the character is 'L', it will return a new cell array with all of the strings in lowercase. If the character is neither 'U' nor 'L', or if the cell array does not contain all strings, the cell array that is returned will be identical to the input cell array. Hint: Look up the iscellstr function. The function file should be named convstrsam 3. Create a cell array variable named cvar that stores a student's name, university ID number, and grade point average (GPA). Initialize it with this data: 'Audrey Hepburn', 97654321, 3.75. Print the contents of the cell arrarz variable. Repeat the exercise, but this time use a structure variable named svar to store the same information. This will demonstrate your ability to create and access items within a cell array versus a structure. Store your work in a script named studenta 4. Suppose we define a structure to store information about the elements in the periodic table of elements. For each element, we store the name, atomic number, chemical symbol, atomic weight, and a four-element vector for the number of electrons in each of the first four shells. Create a script named elementu and initialize an array of structures to store these specific elements hydrogen H 1.0078 1 0 e 0 helium He 4.0026 2 0 0 e lithium Li 6.938 2 1 0 e beryllium Be 9.0122 2 2 0 0 Prompt the user to enter a number from 1 to 4. Display the information for the element stored at that array index location
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