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 !

 Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 5 Mai 2012

0 votes

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));

Plus de réponses (0)

Catégories

En savoir plus sur Aerospace Blockset dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by