Organizing data into a matrix, Generating a matrix

2 ビュー (過去 30 日間)
Muhammad Arsalan
Muhammad Arsalan 2011 年 10 月 31 日
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

採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 10 月 31 日
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 件のコメント
Muhammad Arsalan
Muhammad Arsalan 2011 年 10 月 31 日
Amazing. Works perfectly..... Thanks a lot for quick reply.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by