필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by