Organizing data into a matrix, Generating a matrix

2 vues (au cours des 30 derniers jours)
Muhammad Arsalan
Muhammad Arsalan le 31 Oct 2011
Hi,
I need little help with data manipulation. I have a 250x3 cell that i have imported from excel file. Data looks like:
A B C
100 5 1.0325
100 10 1.5648
100 15 1.1456
200 5 1.8986
200 15 1.6545
300 10 1.9879
So I want to convert this data into a matrix with column A data as X axis and Column B data in Y axis. Something like as follows:
100 200 300 ... so on
5 1.0325 1.8986 0
10 1.5648 0 1.9879
15 1.1456 1.6545 0
.
.
.
so on
This is just an example and actually i have huge amount of data to deal with.
Any idea, help, tips or suggestions are appreciated.
Thanks in advance. //Arsalan

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 31 Oct 2011
A = [100 5 1.0325
100 10 1.5648
100 15 1.1456
200 5 1.8986
200 15 1.6545
300 10 1.9879]
[a1 j1 j1] = unique(A(:,1))
[a2 j2 j2] = unique(A(:,2))
out = [0,a1';a2 accumarray([j2 j1 ],A(:,3),[numel(a2),numel(a1)])]
  1 commentaire
Muhammad Arsalan
Muhammad Arsalan le 31 Oct 2011
Amazing. Works perfectly..... Thanks a lot for quick reply.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

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