Hello, Say I have a list a experimental measures of sea surface current like:
date latitude longitude velocity
31/11/2011 42.333 127.111 2.1
31/11/2011 43.333 123.111 2.3
01/1/2012 42.333 127.111 2.1
01/1/2012 43.333 123.111 2.3
...
Note that I don't have all latitude and longitude data for all dates ( there are some experiments missing).
I would like to reshape this to a 3d array with
1d: date
1d: latitude
1d: longitude
and in the array: the velocity value.
I have looked into reshape and dataset.unstack.. without success... thanks !

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 5 月 5 日

0 投票

d = {'31/11/2011' 42.333 127.111 2.1
'31/11/2011' 43.333 123.111 2.3
'01/1/2012' 42.333 127.111 2.1
'01/1/2012' 43.333 123.111 2.3};
k = [datenum(d(:,1),'dd/mm/yyyy'),cell2mat(d(:,2:end))];
[a,n,n] = arrayfun(@(ii)unique(k(:,ii)),1:size(k,2)-1,'un',0);
p = [n{:}];
out = accumarray(p(:,[2 3 1]),k(:,4));

1 件のコメント

bb
bb 2012 年 5 月 7 日
Thanks very much Andrei !

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeAerospace Blockset についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by