Error in Integration of Cell Array
3 次查看(过去 30 天)
显示 更早的评论
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..?
0 个评论
采纳的回答
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
2020-7-14
What is the role of your thetha_P matrix in this? Why are you indexing it in your code?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!