setting up a nested data structure
129 次查看(过去 30 天)
显示 更早的评论
I have a large data set containing a 300x1 matrix of various male heights and another 300x1 matrix of female heights. I sorted these heights manually using a selection sort algorithm and also using matlab's sort() command. I then timed the manual and matlab excecutions using the tic/toc commands. Basically I need to create a nested strucure that includes the sorted male and female heights as well as the manual and matlab run times for each gender. the included image details what needs to be stored into what
How do I put the manual and matlab data into the appropriate gender (female or male)? here is the code I used (its very wrong)
(female=300x1 height matrix
male=height matrix)
SortedHeights=struct('Female Heights',female,struct('Manual',manual_time,'Matlab',matlab_female),'Male Heights',male,struct('Manual',manual_time,'Matlab',matlab_male))
i apologize if any of my wording is confusing lol
0 个评论
采纳的回答
Jeff Miller
2020-10-20
Your information architecture diagram doesn't look quite right. For example, your [Females] should be a structure that holds heights and times, but you have it as an array of heights. I think you want something like this:
female_times = struct('Manual',manual_time,'Matlab',matlab_female);
Female = struct('Heights',female,'Times',female_times);
% ditto for males to make struct Male
SortedHeights=struct('Female',Female,'Male',Male)
FWIW, I would question using an information architecture like this in the first place. Why not, for example, just keep the times in a 2x2 array (gender, manual/matlab)?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!