Organizing data into a matrix, Generating a matrix

1 view (last 30 days)
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

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 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)])]

More Answers (0)

Community Treasure Hunt

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

Start Hunting!