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

조회 수: 1 (최근 30일)
Clifford Wu
Clifford Wu 2015년 4월 22일
댓글: Clifford Wu 2015년 4월 23일
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
Clifford Wu
Clifford Wu 2015년 4월 23일
편집: Clifford Wu 2015년 4월 23일
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 2015년 4월 23일
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...

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 4월 22일
v=rand(10,10); % Example
out=mean(v(:,1:5),2)-mean(v(:,6:10),2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by