How can I group data in order to build a table?

1 vue (au cours des 30 derniers jours)
MByk
MByk le 1 Oct 2020
Commenté : MByk le 1 Oct 2020
Hello, I want to group values according to the first column which repeats itself in every 5 records and displays the values side by side to build a table like representation. How can I do this? Thanks for the help.
Input:
11.1000 -0.13104830
11.1005 -0.13109738
11.1010 -0.13113159
11.1015 -0.13115123
11.1020 -0.13115658
11.1000 -0.17104830
11.1005 -0.17779738
...
Output:
11.1000 -0.13104830 -0.17104830 ...
11.1005 -0.13109738 -0.17779738 ...
11.1010 -0.13113159 -0.23123433 ...

Réponse acceptée

Ameer Hamza
Ameer Hamza le 1 Oct 2020
Modifié(e) : Ameer Hamza le 1 Oct 2020
Try this
M = [
11.1000 -0.13104830
11.1005 -0.13109738
11.1010 -0.13113159
11.1015 -0.13115123
11.1020 -0.13115658
11.1000 -0.17104830
11.1005 -0.17779738
11.1010 -0.13113159
11.1015 -0.13115123
11.1020 -0.13115658];
[grps, val1] = findgroups(M(:,1));
val2 = splitapply(@(x) {x.'}, M(:,2), grps);
M_out = [val1 cell2mat(val2)];
Result
>> M_out
M_out =
11.1000 -0.1310 -0.1710
11.1005 -0.1311 -0.1778
11.1010 -0.1311 -0.1311
11.1015 -0.1312 -0.1312
11.1020 -0.1312 -0.1312
  1 commentaire
MByk
MByk le 1 Oct 2020
Thank you very much, work like a charm.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by