0
0
MATLABdata~10 mins

Structure arrays in MATLAB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a structure array with field 'name'.

MATLAB
person = struct('[1]', 'Alice');
Drag options to blanks, or click blank then click option'
Aname
Bage
Cheight
Dweight
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name that does not match the data, like 'age' or 'height'.
2fill in blank
medium

Complete the code to add a second element to the structure array.

MATLAB
person(2) = struct('[1]', 'Bob');
Drag options to blanks, or click blank then click option'
Aage
Bheight
Cname
Dweight
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different field name for the second element.
3fill in blank
hard

Fix the error in the code to correctly create a structure array with fields 'name' and 'age'.

MATLAB
person = struct('name', 'Alice', '[1]', 30);
Drag options to blanks, or click blank then click option'
Aweight
Bage
Cbirthdate
Dheight
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated field names like 'height' or 'weight'.
4fill in blank
hard

Fill both blanks to create a structure array with fields 'name' and 'age' for two people.

MATLAB
people(1) = struct('[1]', 'Alice', '[2]', 30);
Drag options to blanks, or click blank then click option'
Aname
Bheight
Cage
Dweight
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the fields or using unrelated field names.
5fill in blank
hard

Fill all three blanks to create a structure array with fields 'name', 'age', and 'height' for two people.

MATLAB
people(2) = struct('[1]', 'Bob', '[2]', 25, '[3]', 180);
Drag options to blanks, or click blank then click option'
Aweight
Bage
Cheight
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong field names or wrong order of fields.