0
0
MATLABdata~10 mins

Structures and field access 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 with a field named 'name'.

MATLAB
person.[1] = 'Alice';
Drag options to blanks, or click blank then click option'
Aweight
Bname
Cheight
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name that does not match the value, like 'age' or 'height'.
Forgetting to use the dot (.) to access the field.
2fill in blank
medium

Complete the code to access the 'age' field from the structure 'person'.

MATLAB
ageValue = person.[1];
Drag options to blanks, or click blank then click option'
Aheight
Bweight
Cname
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong field name like 'height' or 'name'.
Missing the dot (.) before the field name.
3fill in blank
hard

Fix the error in the code to correctly assign the field 'score' in the structure 'student'.

MATLAB
student[1]score = 95;
Drag options to blanks, or click blank then click option'
A.
B:
C;
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using colon (:) or semicolon (;) instead of dot (.) for field access.
Forgetting the dot entirely.
4fill in blank
hard

Fill both blanks to create a structure 'car' with fields 'make' and 'year'.

MATLAB
car.[1] = 'Toyota';
car.[2] = 2020;
Drag options to blanks, or click blank then click option'
Amake
Bmodel
Cyear
Dcolor
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up field names like using 'model' or 'color' instead of 'make' or 'year'.
Forgetting to use the dot (.) before field names.
5fill in blank
hard

Fill all three blanks to create a structure 'book' with fields 'title', 'author', and 'pages'.

MATLAB
book.[1] = '1984';
book.[2] = 'Orwell';
book.[3] = 328;
Drag options to blanks, or click blank then click option'
Aauthor
Bpages
Ctitle
Dpublisher
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect field names like 'publisher' instead of 'author' or 'pages'.
Mixing the order of fields.