saving indexs from matlab mfile
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!