saving indexs from matlab mfile
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have an m.file which calculates nearest distance. in the end i am getting one matrix with value. But i do not want values i want only index of this values. how to save it??
function [ res ] = GNN(Original_data, Measured_data, Gate)
res=nan(size(Original_data));
for iy = 1:size(Original_data,2)
localMeasured_data = Measured_data;
for ix = 1:size(Original_data,1)
localMeasured_data(ix,isnan(localMeasured_data(ix,:)))=0; %end;
less = find(localMeasured_data(ix,:) < (Original_data(ix,iy) - Gate));
more = find(localMeasured_data(ix,:) > (Original_data(ix,iy) + Gate));
if ~isempty(less)
localMeasured_data(ix,less) = NaN;
end
if ~isempty(more)
localMeasured_data(ix,more) = NaN;
end
[~,id]= min(abs(localMeasured_data(ix,:)-Original_data(ix,iy))); %%%i want to save this ids in a matrix
res(ix,iy) = localMeasured_data(ix,id);
end
end
end
0 commentaires
Réponse acceptée
KSSV
le 15 Mar 2016
function [ res,iwant ] = GNN(Original_data, Measured_data, Gate)
res=nan(size(Original_data));
iwant = zeros(size(Original_data,1),1) ;
for iy = 1:size(Original_data,2)
localMeasured_data = Measured_data;
for ix = 1:size(Original_data,1)
localMeasured_data(ix,isnan(localMeasured_data(ix,:)))=0; %end;
less = find(localMeasured_data(ix,:) < (Original_data(ix,iy) - Gate));
more = find(localMeasured_data(ix,:) > (Original_data(ix,iy) + Gate));
if ~isempty(less)
localMeasured_data(ix,less) = NaN;
end
if ~isempty(more)
localMeasured_data(ix,more) = NaN;
end
[~,id]= min(abs(localMeasured_data(ix,:)-Original_data(ix,iy))); %%%i want to save this ids in a matrix
iwant(ix) = id ;
res(ix,iy) = localMeasured_data(ix,id);
end
end
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and 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!