same number in the vector

1 次查看(过去 30 天)
I want to use all the same number in the vector for one equation and another numbers for another equaion
ex: my vecotr is h=[0.12;0.1;0.1;0.04;0.04;0.04;0.1;0.1;0.1;0.06;0.1]
here 0.1 repeated 5 times and 0.04 3 times ..i want to use these numbers for one eq and another for another eq
thanks

采纳的回答

Chunru
Chunru 2021-11-27
编辑:Chunru 2021-11-27
h=[0.12;0.1;0.1;0.04;0.04;0.04;0.1;0.1;0.1;0.06;0.1]
h = 11×1
0.1200 0.1000 0.1000 0.0400 0.0400 0.0400 0.1000 0.1000 0.1000 0.0600
hu = unique(h);
idx = sum(h -hu' == 0) > 1;
hrep = hu(idx)
hrep = 2×1
0.0400 0.1000

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by