how can i use arrayfun to split a timeseries with multivariates into separate timeseries?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!