Filtering dates from matrix

1 visualizzazione (ultimi 30 giorni)
AA
AA il 23 Ott 2017
Modificato: Cam Salzberger il 23 Ott 2017
I have got a cell array with 'out' 1x1 which has a matrix with one million rows and 6colummns. First row contains date serial numbers. I want to filter out the rows that contain the date serial number found in the variable 'result'. Unfortunately, my following formula does not work. Is there any other way which is faster, i.e. Can I do the filtering directly in the matrix?
for x = 1:1 leon=ismember(out{x}(:,1),result); leonsum{x}=find(sum(leon,2)); out1{x}=out{x}(leonsum{x},1:6); end
Error:
Undefined function 'find' for input arguments of type 'cell'.

Risposta accettata

Cam Salzberger
Cam Salzberger il 23 Ott 2017
Modificato: Cam Salzberger il 23 Ott 2017
A 1x1 cell isn't much use to anyone, so it's probably easiest to just extract the matrix from inside:
outData = out{1};
Then you can use ismember on the first column of the data and "result" to determine which rows to remove:
whichToRemove = ismember(outData(:, 1), result);
Then remove the data you don't want:
outFiltered = outData(~whichToRemove, :);
I'm honestly not sure what you're doing with "leon" and "leonSum", but this is what you described.
-Cam

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by