Effacer les filtres
Effacer les filtres

Replace values in a array

2 vues (au cours des 30 derniers jours)
Miguel Albuquerque
Miguel Albuquerque le 20 Juil 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 commentaires
dpb
dpb le 20 Juil 2022
That does what you asked for...I'm not trying to decipher/debug yours...
Miguel Albuquerque
Miguel Albuquerque le 20 Juil 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by