saving indexs from matlab mfile
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mayank Lakhani
el 15 de Mzo. de 2016
Respondida: KSSV
el 15 de Mzo. de 2016
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 comentarios
Respuesta aceptada
KSSV
el 15 de Mzo. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!