Calculating the strangeness using k constant

1 回表示 (過去 30 日間)
Tino
Tino 2019 年 4 月 10 日
コメント済み: Stephen23 2019 年 4 月 10 日
A B
_______ __
0.57446 C1
0.61644 C2
0.93808 C1
2.1817 C2
2.9883 C1
3.1654 C2
if I want to do this calculations such divide all the sums of C1 by all the sums of C2 how do I go about it. using a constant suck as K to determine the number to sum.
for instance if k = 2
strangeness = sum of the smallest 2 numbers of c1/ sum of the smallest 2 numbers of c2
if K = 3
strangeness = sum of the smallest 3 numbers of c1/sum of the smallest 3 numbers of C2
Thanks in advance
Jonathan

回答 (1 件)

Stephen23
Stephen23 2019 年 4 月 10 日
>> a = [0.6164;3.1654;0.5745;2.9883;0.9381;2.1817];
>> c1 = sort(a(1:2:end));
>> c2 = sort(a(2:2:end));
>> K = 2;
>> sum(c1(1:K))/sum(c2(1:K))
ans = 0.23035
  2 件のコメント
Stephen23
Stephen23 2019 年 4 月 10 日
Jonathan Etumusei's "Answer" moved here:
Hi Stephen thanks for your swift response
>> c1 = sort(totalY11(1:2:end));
I am getting the error
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript.
How do I go about it
Thanks in advance
sorry got it sorted was because the table is in the form
A B
_______ __
0.57446 C1
0.61644 C2
0.93808 C1
2.1817 C2
2.9883 C1
3.1654 C2
Stephen23
Stephen23 2019 年 4 月 10 日
a = NameOfYourTable.A

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

カテゴリ

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

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by