how do I subtract and then mean in every row of a data set?

1 vue (au cours des 30 derniers jours)
Clifford Wu
Clifford Wu le 22 Avr 2015
Commenté : Clifford Wu le 23 Avr 2015
Say I had a 10000x10 matrix, and in every row. I wanted to take the conditional mean for columns 1-5 and 6-10, get the difference of these two means, and then make that appear in a new data set in the corresponding row. Would I use for loop? I am new to mat lab so I'm not sure how to use it Thank you
  4 commentaires
Clifford Wu
Clifford Wu le 23 Avr 2015
Modifié(e) : Clifford Wu le 23 Avr 2015
The conditional mean for columns 1-5 means i take the probabilities used to generate columns 1-5, multiply them by 1-5, and then add them up, for example if p=[.1 .1 .1 .1 .1 .1 .1 .1 .1 .1] i would get (1*.1+2*.1...+5*.1)+(1*.1+2*.1...+5*.1)
Clifford Wu
Clifford Wu le 23 Avr 2015
Image Analyst - the dataset was a random distribution with probabilities for 10 binomials, it went something like mnrnd(7866,p,10000) I'd like the difference of the means to appear in a new data set, optimally, so I could just do mean(newdataset) in the end...

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 22 Avr 2015
v=rand(10,10); % Example
out=mean(v(:,1:5),2)-mean(v(:,6:10),2)
  1 commentaire
Clifford Wu
Clifford Wu le 23 Avr 2015
Simple, understandable for a matlab scrub... thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by