How do I target values within a range for different variables within the same given time series?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
For example I have 4 variables withing a timeseries that records data at 10 hz for an interval of 600 seconds. This results in 4 arrays (1x6000). Say the variables are Speed, Distance, Elevation, and Air Temperature. I want to catagorize these variables based on elevation. Say I want to know the speed, distance, and air temperatures based on every 100ft I travel in elevation. Say 100ft, 200ft, 300ft, etc. all the way up to 1000ft. I won't travel the same distance or move at the same speed for each elevation level, so this would result in different sized arrays for each 100ft of elevation. I have been successfully targeting one variable at a time, but I am having trouble creating a loop that would obtain the information to catagorize the data togehter at each elevation level.
segments.sample.start = 0;
segments.sample.stop = 6000;
segments.freq=.1;%seconds per sample
time = (segments.sample.start:segments.sample.stop)*segments.freq;
p10 = find(elevation>=1000);
p9 = find(elevation>=900 elevation<100);
p8 = find(elevation>=800 & elevation<900);
p7 = find(elevation>=700 & elevation<800);
p6 = find(elevation>=600 & elevation<700);
p5 = find(elevation>=500 & elevation<600);
p4 = find(elevation>=400 & elevation<500);
p3 = find(elevation>=300 & elevation<400);
p2 = find(elevation>=200 & elevation<300);
p1 = find(elevation>=100 & elevation<200);
0 comentarios
Respuestas (1)
Star Strider
el 11 de En. de 2024
I do not completely understand what the data are, or the lengths or content of the various data arrays.
It might be worthwhile to consider interpolating the various values, exspecially if they have a specific set of variables in common (for example the time of the observation, although I cannot determine if time is recorded for each observation from the information provided). Using the interp1 function for example could provide a common set of interpolated values (as a matrix) that could then be used for more general interpolations. Other interpolation funcitons could be appropriate, such as scatteredInterpolant or interpn.
It would help to have the data, or a representative sample of it, as well as a descirption of a typical task.
2 comentarios
Star Strider
el 11 de En. de 2024
Editada: Star Strider
el 12 de En. de 2024
I am stil not certain what your data are or what you are doing.
There are MATLAB functions that make the data binning much easier, one of which is accumarray. There are others such as findgroups, groupsummary, and splitapply that would also work. I have more experience with accumarray, so I use it here.
Example —
time = datetime(2024,1,11) + seconds(0:3599).'; % Time Vector (1 Hz Samplinmg Frequency)
elev = sort(randi([100 1000],size(time))); % Elevations (Rounded To Hundreds)
% [e1,e2] = bounds(elev)
Data = table(time,elev) % Hypothetical Data
figure
stairs(Data.time, Data.elev)
grid
xlabel('Time')
ylabel('Elevation')
elev_d = round(Data.elev/100)*100;
[U_elev,~,eix] = unique(elev_d, 'stable');
elev_time = accumarray(eix, (1:numel(eix)).', [], @(x) max(minute(Data.time(x)))-min(minute(Data.time(x))) );
Result = table(U_elev, elev_time)
Real data might have more complicationos and so be more difficult to deal with. This is simply an illustration of how I might go about analysing it.
EDIT — (12 Jan 2024 at 02:35)
Added second example with some variation in the elevation profile.
time = datetime(2024,1,11) + seconds(0:3599).'; % Time Vector (1 Hz Samplinmg Frequency)
elev = sort(randi([100 1000],size(time))); % Elevations (Rounded To Hundreds)
% [e1,e2] = bounds(elev)
Data = table(time,elev); % Hypothetical Data
Data.elev = Data.elev + 28*sin(2*pi*(0:3599)/810).'
figure
stairs(Data.time, Data.elev)
grid
xlabel('Time')
ylabel('Elevation')
elev_d = round(Data.elev/100)*100;
[U_elev,~,eix] = unique(elev_d, 'stable');
elev_time = accumarray(eix, (1:numel(eix)).', [], @(x) max(minute(Data.time(x)))-min(minute(Data.time(x))) );
Result = table(U_elev, elev_time)
.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!