Calculating the strangeness using k constant

2 vues (au cours des 30 derniers jours)
Tino
Tino le 10 Avr 2019
Commenté : Stephen23 le 10 Avr 2019
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

Réponses (1)

Stephen23
Stephen23 le 10 Avr 2019
>> 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 commentaires
Stephen23
Stephen23 le 10 Avr 2019
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 le 10 Avr 2019
a = NameOfYourTable.A

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by