mean without stable step

3 次查看(过去 30 天)
Fani
Fani 2014-9-25
回答: Fani 2014-9-25
Hi all! I need your help please!
my data are 3033 lines and 2005 columns. I want to find the mean for all columns separately but the step in lines is different. For example, i want to find the mean for the first 167 lines, then from 168 to 294, 295 to 428 and so on. what code can i write?
Thank you!

采纳的回答

Fani
Fani 2014-9-25
This works perfect!!!
Thank you very much for your time!!!

更多回答(3 个)

Mikhail
Mikhail 2014-9-25
You can write a=mean(M,2) - this will find mean of matrix M along each column. And then take only values you need. For 3033*2005 this is ok.
  2 个评论
Mikhail
Mikhail 2014-9-25
Sorry, for columns use a=mean(M), or a=mean(M,1)
Mikhail
Mikhail 2014-9-25
Otherwise you can do it with for loop

请先登录,再进行评论。


Fani
Fani 2014-9-25
In the same column the step is different. For example, in the first column i want to find mean for the first 167 lines, then from 168 to 294,295 to 459 and so on. And this for all columns.
  1 个评论
Mikhail
Mikhail 2014-9-25
ok, so you create vector containing number of lines you want to take: a=[1:167,168...].
If you want to take into account only this lines for all columns, you can make new matrix: N=M(a,:). The new matrix contains only lines you need. And use mean.

请先登录,再进行评论。


Fani
Fani 2014-9-25
if i do this, i take mean for all these lines. I would like to take mean for 1:167, other mean for lines 168:294 and so on.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by