setting up a nested data structure
127 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
scobug411
el 20 de Oct. de 2020
Comentada: scobug411
el 21 de Oct. de 2020
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 comentarios
Respuesta aceptada
Jeff Miller
el 20 de Oct. de 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)?
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!