how can i use arrayfun to split a timeseries with multivariates into separate timeseries?

1 次查看(过去 30 天)
hi all - looking for some help to do this quickly with arrayfun or something similar a is multivariate a = [ value zoneId] [ time] with multiple zoneId for each "time", but only 1 value... I'd like to split out into a circa like a table with ZoneId across the colum and value down the row linked with the "time value"... but this can be achieved with a "set" of time series for each zoneId. any help gratefully appreciated!
if true
a = [ 1.5 101 ; 2 102 ; 1 101 ; 2 102 ; 3 101; 2 102; 3 103];
time = datenum( ['1/1/2005' ; '1/1/2005' ;'1/2/2005' ;'1/2/2005'...
; '1/3/2005' ; '1/3/2005'; '1/3/2005']);
ts = timeseries(a, time);
zoneList = unique(a(:,2));
idx101 = a(:,2) == 101;
idx102 = a(:,2) == 102;
idx103 = a(:,2) == 103;
% for simplicty i have labled idx101 , but in actualitye the size of zoneList
% may vary making it required to handle this differnetly...
tsgroup = repmat(timeseries, size(zoneList));
tsgroup(1) = timeseries( a(idx101,1) , time(idx101))
tsgroup(2) = timeseries( a(idx102,1), time(idx102))
tsgroup(3) = timeseries( a(idx103,1) , time(idx103))
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by