reshaping a set of data

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 !

 Risposta accettata

Andrei Bobrov
Andrei Bobrov il 5 Mag 2012
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));

Più risposte (0)

Categorie

Scopri di più su Aerospace Blockset in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by