Change values in an array based on existing values?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I've been looking through previous questions and nothing I've found worked quite well. I thought of using uniquetol but that a) didn't 100% address this problem and b) was not available in 2013a.
I have an array (timestamp_comp) with 2 columns of data. I want to filter the rows in that array based on the value of a cell in another array. Starting out:
%%Finds row in timestamp_comp that approximately matches values in timestamp_meta
e= 1e-5;
crtimestamp_comp=zeros(size(timestamp_comp));
for compare= timestamp_comp(:,2)-timestamp_meta(:,2)
if compare > e
crtimestamp_comp(:,:)=0;
else
crtimestamp_comp(:,:)=timestamp_comp(:,:);
end
end
Here I'm trying to convert all the rows in timestamp_comp that differ more than 1e-5 in the second column from timestamp_meta to zero and then all of the ones that are similar enough are kept.
0 Commenti
Risposte (1)
Andrei Bobrov
il 21 Feb 2016
Maybe so
crtimestamp_comp = timestamp_comp;
t = abs(timestamp_comp(:,2)-timestamp_meta(:,2)) > 1e-5;
crtimestamp_comp(t,:) = 0;
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!