setting up a nested data structure
127 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Jeff Miller
le 20 Oct 2020
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)?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!