フィルターのクリア

Replace values in a array

2 ビュー (過去 30 日間)
Miguel Albuquerque
Miguel Albuquerque 2022 年 7 月 20 日
コメント済み: Miguel Albuquerque 2022 年 7 月 20 日
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 件のコメント
dpb
dpb 2022 年 7 月 20 日
That does what you asked for...I'm not trying to decipher/debug yours...
Miguel Albuquerque
Miguel Albuquerque 2022 年 7 月 20 日
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

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by