I have the following way of subarray manipulation. I have an array called arr of dimension rxc, i loop goes from 1 to r-n, j loop goes from 1 to c-n, and I use as:
x=somefn(arr(i:i+n-1,j:j+n-1)(:),a);
I am getting error stating: cannot call or index to a temporary array at the :, please suggest remedy.

댓글 수: 1

This is not valid MATLAB syntax:
x=somefn(arr(i:i+n-1,j:j+n-1)(:),a);
↑↑↑
Please explain in some detail what you want to do.

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

 채택된 답변

Guillaume
Guillaume 2017년 5월 22일

1 개 추천

You can't chain indexing operations, so you can either create a temporary variable
subarr = arr(i:i+n-1, j:j+n-1);
x = somefn(subarr(:), a);
Or, since the colon here just does a reshape, call reshape explicitly:
x = somefn(reshape(arr(i:i+n-1, j:j+n-1), [], 1), a);

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Propagation and Channel Models에 대해 자세히 알아보기

태그

질문:

2017년 5월 22일

댓글:

2017년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by