Opening the book…
Exercise 1:
Create a cell array named mixedData that stores your first name, your favorite number, a vector of three numbers, and a logical value. Display each item using curly brace indexing.
Exercise 2:
Create a 2-by-3 cell array. Store text in the first row and numbers in the second row. The in one line of code, extract the value in row 2, column 3.
Exercise 3:
Create a cell array named phrases that stores at least five motivational phrases. Use randi to randomly display one phrase.
Exercise 4:
Create a structure named book with fields Title, Author, Year, and Pages. Display the Title field.
Exercise 5:
Create a structure named sensor with fields ID, Location, Units, and Reading. Change the Reading field to a new value.
Exercise 6:
Create a cell array named cars that stores information about three cars. Each row should contain make, model, year, and mileage. Extract the mileage column.
Exercise 7:
Create a script named studentInfo that prompts a student for first name, last name, student ID number, and GPA. Store the information in a structure and print a sentence summarizing the information.
Exercise 8:
Create a structure array named students with three students. Each student should have fields FirstName, LastName, ID, and GPA. Create a vector containing all GPAs.
Exercise 9:
Create a structure array named parts with fields item_no, cost, price, and code. Calculate the profit for each part and store it in a new field named profit.
Exercise 10:
Write a script that converts a cell array of bood donor information into a structure array with fields Last, First, Type, Rh, Systolic, and Diastolic.
Exercise 11:
Create a table named studentsTable with variables FirstName, LastName, ID, and GPA for at least four students. Extract the GPA variable and calculate the average GPA.
Exercise 12:
Create a table of car information with variables Make, Model, Year, and Mileage. Use logical indexing to display only the cars with mileage less than 50000.
Exercise 13:
Convert a small cell array of donor information into a table with meaningful variable names. Then use dot notation to extract one column.
Exercise 14:
Write a function named cellParse that takes a cell array as input. Each element may be a string, character vector, numeric vector, or logical value. The function should return the number of strings, character vectors, numeric arrays, and logical values in the cell array.
Exercise 15:
Write a script named makeClothes that creates a structure array of clothing items. Then write a local function named rateClothes that adds Rating and Quality fields to each item using the rating equation in this chapter.
Exercise 16:
Write a function named usedCar that takes a car structure with fields Make, Year, Cost, Miles, and Accidents. Adjust the Cost field according to the rules in the used car example.
Exercise 17:
Create a small inventory system using a structure array. Each item should have fields Name, Quantity, UnitCost, and Category. Write code that calculates the total value of the inventory.
This page titled 8.9: Chapter Exercises was last modified on Tue, 30 Jun 2026 02:12:02 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.
The book could not be loaded just now.