Matlab Structure & Table Quiz
40 comprehensive questions on MATLAB's structure and table data types covering struct fields, nested structures, table creation, row/column access, and table operations — with 16 code examples to master MATLAB's cpp quiz structured data capabilities.
Question 1
What is a structure in MATLAB?
Question 2
How do you create a structure in MATLAB?
person.name = 'John';
person.age = 30;
person.city = 'Boston';Question 3
How do you access structure fields?
person.name = 'John';
name_value = person.name;Question 4
What is a nested structure?
company.employee.name = 'John';
company.employee.age = 30;Question 5
How do you create a table in MATLAB?
names = {'John'; 'Jane'; 'Bob'};
ages = [30; 25; 35];
table_data = table(names, ages, 'VariableNames', {'Name', 'Age'});Question 6
How do you access table columns?
T = table({'John'; 'Jane'}, [30; 25], 'VariableNames', {'Name', 'Age'});
names = T.Name;Question 7
What does the struct function do?
person = struct('name', 'John', 'age', 30, 'city', 'Boston');Question 8
How do you access table rows?
T = table({'John'; 'Jane'}, [30; 25], 'VariableNames', {'Name', 'Age'});
first_row = T(1, :);Question 9
What is the fieldnames function used for?
person.name = 'John';
person.age = 30;
fields = fieldnames(person);Question 10
How do you add new fields to a structure?
person.name = 'John';
person.age = 30;
person.city = 'Boston';Question 11
What does the isfield function check?
person.name = 'John';
has_age = isfield(person, 'age');Question 12
How do you sort a table by a column?
T = table({'John'; 'Jane'; 'Bob'}, [30; 25; 35], 'VariableNames', {'Name', 'Age'});
sorted_T = sortrows(T, 'Age');Question 13
What is an array of structures?
people(1).name = 'John';
people(1).age = 30;
people(2).name = 'Jane';
people(2).age = 25;Question 14
How do you remove fields from a structure?
person.name = 'John';
person.age = 30;
person = rmfield(person, 'age');Question 15
What does the height function return for tables?
T = table({'John'; 'Jane'}, [30; 25], 'VariableNames', {'Name', 'Age'});
num_rows = height(T);Question 16
How do you create tables from arrays?
data = [1 2; 3 4; 5 6];
T = array2table(data, 'VariableNames', {'Col1', 'Col2'});Question 17
What is the difference between structures and tables?
Question 18
How do you filter table data?
Question 19
What does the getfield function do?
Question 20
How do you merge tables?
Question 21
What is the setfield function used for?
Question 22
How do you add rows to a table?
Question 23
What does the width function return for tables?
Question 24
How do you handle missing data in tables?
Question 25
What is the struct2table function used for?
Question 26
How do you group table data?
Question 27
What does the orderfields function do?
Question 28
How do you convert tables to arrays?
Question 29
What is the table2struct function used for?
Question 30
How do you handle duplicate table rows?
Question 31
What does the vartype function do?
Question 32
How do you pivot table data?
Question 33
What is the difference between struct arrays and cell arrays?
Question 34
How do you validate table data types?
Question 35
What does the summary function provide for tables?
Question 36
How do you handle nested structures programmatically?
Question 37
What is the table2cell function used for?
Question 38
How do you perform calculations on table columns?
Question 39
What does the isstruct function check?
Question 40
Considering MATLAB's structured data capabilities as a whole, what fundamental advantage do tables provide compared to structures for data analysis workflows?
