Hello,I Have the following dataset, I want to delete the value which are multiple of any value present in array.
For example in this array 70 is present which is multiple of 35.

 採用された回答

Dyuman Joshi
Dyuman Joshi 2022 年 12 月 27 日
編集済み: Dyuman Joshi 2022 年 12 月 27 日

0 投票

y=load('multiple.mat').Value;
%all the different value present in the array
z=unique(y)
z = 1×6
35 40 45 50 55 70
for j=unique(y)
y( (rem(y,j)==0) & y~=j )=[];
end
y
y = 1×1410
35 35 35 35 35 35 35 40 45 50 55 35 35 35 35 35 35 35 35 35 35 40 45 50 55 35 35 35 35 35

5 件のコメント

Med Future
Med Future 2022 年 12 月 27 日
@Dyuman Joshi Not like this, I want a algo in which if multiple of any value exist it will delete those values
Med Future
Med Future 2022 年 12 月 27 日
Like in the following new array, I have the value 70, 80,90,100
Which are the multiple of 35,40,45 and 50. I want to remove the values which are multiple of any value present in array.
Dyuman Joshi
Dyuman Joshi 2022 年 12 月 27 日
編集済み: Dyuman Joshi 2022 年 12 月 27 日
"Not like this, I want a algo in which if multiple of any value exist it will delete those values"
That is what I wrote. You only mentioned a single value and I wrote a code according to that.
Are 30, 40, 45 and 50 the only values whose multiples you want to delete? Or do you want to delete the multiple of smallest values?
Med Future
Med Future 2022 年 12 月 27 日
@Dyuman Joshi I want to delete those values in array, which are multiple of any value present in array.
Dyuman Joshi
Dyuman Joshi 2022 年 12 月 27 日
I have edited my answer, please take a look at it again.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

リリース

R2021b

質問済み:

2022 年 12 月 27 日

コメント済み:

2022 年 12 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by