I have a array of 61 number, i want to take mean of 1st and 17th number, then 2nd and 18th number and then want to put this mean values in a array?

조회 수: 2 (최근 30일)
I don't want to use loop here.

답변 (1개)

KSSV
KSSV 2021년 7월 29일
A = rand(1,61) ;
idx = [(1:46)' (16:61)'] ; % get indices
iwant = mean(A(idx),2)
  댓글 수: 7
KSSV
KSSV 2021년 7월 29일
A = rand(180,270,61) ;
idx = [(1:46)' (16:61)'] ;
B = zeros(180,270,46,2) ;
B(:,:,:,1) = A(:,:,idx(:,1)) ;
B(:,:,:,2) = A(:,:,idx(:,2)) ;
Check and then use....confirm the result with a loop.
Subhodh Sharma
Subhodh Sharma 2021년 7월 29일
@kssv thanks for your help, but this not what I was looking for. I solved it.
Thanks man!

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

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by