find and save the rows where condition is met

4 Ansichten (letzte 30 Tage)
C.G.
C.G. am 28 Jan. 2021
Kommentiert: C.G. am 29 Jan. 2021
I have a 1x3001 cell, 'y', and I want matlab to loop through all the cells and save all the rows where the value in column 2 is <-0.13.
I have the following code but i get the error below. Please could somebody help me fix this?
%for all the csv files (3001)
for b = 1:length(data)
%get the ID number (:,1) and coordinates (:,6) and save them in an array
y{b} = table2array(data{b}(:,[1 6]));
%find and save all the rows in each csv file where column 2 is <-0.13
g{b} = y{b}(y(:,2) <= -0.13, :);
end
Undefined operator '<=' for input arguments of type 'cell'.

Akzeptierte Antwort

David Hill
David Hill am 28 Jan. 2021
for b = 1:length(data)
%get the ID number (:,1) and coordinates (:,6) and save them in an array
y{b} = table2array(data{b}(:,[1 6]));
%find and save all the rows in each csv file where column 2 is <-0.13
g{b} = y{b}(y{b}(:,2) <= -0.13, :);
end

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by