People
Companies
Institutions
Jobs
Q&A
News
AI Dasatoo
Log in
Home
Courses
Tutors
Books
Q&A
Ask and answer questions to make information more available to wider audiences.
Tags
Latest
Ask Question
Bailey Leach
@
leachbailey
22, Aug 2023 12:00 AM
containers.Map
How to iterate over the keys and elements of a containers.Map?
Iterate over the keys and elements of D:
D = containers.Map({'2R175', 'B7398', 'A479GY', 'NZ1452'}, ...
{'James Enright', 'Carl Haynes', 'Sarah Latham', ...
'Bradley Reid'});
answers
1
Answer 1
Drake Boot
@
bootdrake85
31, Aug 2023 03:19 PM
Obtain the keys.
Get the values.
Iterate over the elements accessing them with {}.
k = keys(D) ;
val = values(D) ;
for i = 1:length(D)
[k{i} val{i}]
end
Output:
ans =
'2R175James Enright'
ans =
'A479GYSarah Latham'
ans =
'B7398Carl Haynes'
ans =
'NZ1452Bradley Reid'