find and save the rows where condition is met

4 vues (au cours des 30 derniers jours)
C.G.
C.G. le 28 Jan 2021
Commenté : C.G. le 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'.

Réponse acceptée

David Hill
David Hill le 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

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by