Extracting specific parts of an array

I have two sets of data in a 1x500000 array (data_time and data_velocity). I want to extract the values from both arrays, where the data_velocity is <0.1 and >-0.1 to a separate array. The goal is to extract the data where there is near zero velocity, but keep the time values.

Antworten (1)

Mischa Kim
Mischa Kim am 5 Jan. 2021
Bearbeitet: Mischa Kim am 5 Jan. 2021

0 Stimmen

Assuming your variable is called data_velocity use something like:
extractdata = data_velocity(data_velocity<0.1 & data_velocity>-0.1)

3 Kommentare

Joe Brague
Joe Brague am 7 Jan. 2021
Lets say data is a 2x500000 array containing both data_velocity and data_time. How can I extract the specific values (of data_velocity and data_time) where the data_velocity is <0.1 and >-0.1 to a separate array.
There are a couple of ways to achieve this. E.g.
data = [1 2 3 0 5 6 7 8 9 10;...
0.1 0 0 -0.2 -0.1 0 0 0 0.05 -0.05];
[row,col] = find(data(:,:)<0.1 & data(:,:)>-0.1);
extractdata = data(:,col)
Joe Brague
Joe Brague am 8 Jan. 2021
I think the last issue is that the time array is staying the same (~300 seconds), even though I am excluding velocities <-0.1 and >0.1. Is there a way to only extract the relevant data included in the parameters? to a single concatenated array?

Melden Sie sich an, um zu kommentieren.

Kategorien

Gefragt:

am 5 Jan. 2021

Kommentiert:

am 8 Jan. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by