store strings and numbers into an array
Show older comments
hello everybody,
i'am still a beginner in MATLAB and need your help.
if i have a list of Person names and their ages. e.g. Peter: 28; Fabian: 21; Mary: 32.
how to create an array in MATLAB including these informations and how to access them on the base of the name or age.
I appreciate every help.
thank you
Accepted Answer
More Answers (1)
% You can use structure array
PersonInfo(1) = struct("Name", "Peter", "Age", 28);
PersonInfo(2) = struct("Name", "Fabian", "Age", 21);
PersonInfo(3) = struct("Name", "Mary", "Age", 32);
PersonInfo(1)
1 Comment
Youssef Darwich
on 8 Jan 2022
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!