mean value of array after every n columns

조회 수: 1 (최근 30일)
Fatma Nur Disci
Fatma Nur Disci 2020년 12월 8일
편집: Fatma Nur Disci 2020년 12월 16일
Hi,
I have 1x131072 dataPower array read from matfile. And want to average each every 128 columns. What's the problem here ?
a = matfile('x');
b=a.dataPower; %dataPower array
bround=round(b(1:131072) % array include double values like 297.3865 and just try to cast to 297 for example.
for i = 1024
k(i) = mean(bround((i-1)*128+1:i*128),2)
end
And want to get 1024 value. But error : subscript indices must either be real positive integers or logicials.
Thanks.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 8일
Here is a loop-free option
a = matfile('x');
b=a.dataPower; %dataPower array
bround=round(b(1:131072));
k = mean(reshape(bround, 128, []))
  댓글 수: 1
Fatma Nur Disci
Fatma Nur Disci 2020년 12월 16일
편집: Fatma Nur Disci 2020년 12월 16일
Hi , I thought that I was deleting this question bcs after asked it, I solved my problem, but it still appears. Thanks for your help, anyway.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by