Replace values in a array

4 visualizaciones (últimos 30 días)
Miguel Albuquerque
Miguel Albuquerque el 20 de Jul. de 2022
Comentada: Miguel Albuquerque el 20 de Jul. de 2022
Hey to all, thanks in advance
Is there a way of: for each row of distance_matrix, for the values that are not zero,find the most aproximate values in the array range with those of that row in distance_matrix. Once we identified in which column the values are most similar to those in the row of distance_matrix, replace those values in range by the values present in each row of RMC2.
Thank you
  8 comentarios
dpb
dpb el 20 de Jul. de 2022
That does what you asked for...I'm not trying to decipher/debug yours...
Miguel Albuquerque
Miguel Albuquerque el 20 de Jul. de 2022
done
distance_matrix=round(distance_matrix);
range=round(range);
RMC2=round(RMC2);
for i =1:size(RMC2,1)
thisrow=RMC2(i,:)
thisrow2=distance_matrix(i,:)
isR2=find(thisrow2)
thisrow2=distance_matrix(i,isR2)
[val,pos]=intersect(range,thisrow2)
pos=pos.';
first_element=pos(1,1)
last_element=pos(1,end)
value=(last_element-first_element)+1
thisrow=RMC2(i,(1:value))
range(1,(first_element:last_element))=thisrow
end

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by