How do I extract values from one table and match them to coordinates in another table?

4 vues (au cours des 30 derniers jours)
Onur Guler
Onur Guler le 3 Août 2021
Commenté : Onur Guler le 6 Août 2021
I have a table which contains 32 imported csv files ('DataTable') which shows the position of an object and its x-axis load and y-axis load. I have grouped the individual coordinates into ranges to create 70 areas in a 10x7 grid using groupsummary. I have used groupsummary to include the means and standard deviations of the x and y loads within each area ('StatsTable'). I then want to align these results (mean and standard deviations results) to correspond with the individual coordinates into a seperate table. This new table would have the X Positions, Y Positions, X Loads and Y Loads from 'DataTable' in columns 1,2,3 and 4. In the 5th, 6th, 7th and 8th column, it would have the X and Y means and standard deviations from 'StatsTable'.
Effectively, what I want to do is attach the correct mean and standard deviation values to the individual coordinates depending which range group they belong to.
relevant code and images are below. Thanks in advance.
ds = tabularTextDatastore('Filepath','FileExtensions','.csv');
DataTable = readall(ds);
StatsTable = groupsummary(DataTable,{'XPos','YPos',},{[-1740 -1566 -1392 -1218 -1044 -870 -696 -522 -348 -174 1],[-760 -616 -471 -327 -182 -39 106 251]},{'mean','std'},{'XLoad','YLoad'},'IncludeEmptyGroups',true);
  2 commentaires
Peter Perkins
Peter Perkins le 5 Août 2021
You can use join to do this, but you will need to add the disc_XPos and disc_YPos values to the original table. Applying discretize to XPos and YPos is the way to do that, I think. Then just join on those two variables as keys.
Onur Guler
Onur Guler le 6 Août 2021
Thanks for your suggestion. I will give this a try.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Tables 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!

Translated by