Replace values in a array

5 visualizzazioni (ultimi 30 giorni)
Miguel Albuquerque
Miguel Albuquerque il 20 Lug 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 Commenti
dpb
dpb il 20 Lug 2022
That does what you asked for...I'm not trying to decipher/debug yours...
Miguel Albuquerque
Miguel Albuquerque il 20 Lug 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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by