Error in Integration of Cell Array

조회 수: 1 (최근 30일)
Chris Dan
Chris Dan 2020년 7월 13일
댓글: Chris Dan 2020년 7월 15일
Hello,
I am trying to perform integration on a cell array using the following code:
r = 2;
phi_e = 1.3694;
for e =1:1:size(A_schnitt,1)
for y =1:1:size(A_schnitt{e,1},1)
for u =1:1:size(A_schnitt{e,1},2)
fun= @(thetha_P) ((1/(2*pi))*A_schnitt{e,1}{y,u}.*exp(-1i*r*thetha_P(y,u)));
A{e,y,u}= integral(fun,0,phi_e, 'ArrayValued',true)
end
end
end
I am attaching the files
A_schnitt a multipel cell array which contains (5x1 cells, then each cell contains 3x63 cells and each cell is than a 2x2 matrix) and thetha_P which is a 3x63 double array.
The error which I am getting is
Index in position 2 exceeds array bounds (must not exceed 1).
Error in integralCalc/iterateArrayValued (line 156)
Error in integralCalc/iterateArrayValued (line 156)
fxj = FUN(t(1)).*w(1);
Error in integralCalc/vadapt (line 130)
[q,errbnd] = iterateArrayValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
Does anyone knows..?

채택된 답변

Walter Roberson
Walter Roberson 2020년 7월 13일
fun= @(thetha_P) ((1/(2*pi))*A_schnitt{e,1}{y,u}.*exp(-1i*r*thetha_P(y,u)));
A{e,y,u}= integral(fun,0,phi_e, 'ArrayValued',true)
integral() is going to call the given function. Normally it would pass in a vector of values, but because you indicated ArrayValued as true, integral() is going to pass in one value at a time.
Inside your anonymous function, that scalar value is going to be received as the variable thetha_P . As indicated, it will be a scalar. But you attempt to index it with thetha_P(y,u)
thetha_P which is a 3x63 double array.
Not inside that anonymous function it will not be. You said @(thetha_P) so inside the anonymous function thetha_P is what is passed in, not whatever value thetha_P might have in the workspace.
I have to ask what variable you are integrating with respect to? What value in fun is intended to range over 0 to phi_e with the integral being formed out of it?
  댓글 수: 3
Walter Roberson
Walter Roberson 2020년 7월 14일
What is the role of your thetha_P matrix in this? Why are you indexing it in your code?
Chris Dan
Chris Dan 2020년 7월 15일
I got it actually, I had to use another variable for integration apart from thetha_P, then it works

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by