Error in Integration of Cell Array

2 visualizaciones (últimos 30 días)
Chris Dan
Chris Dan el 13 de Jul. de 2020
Comentada: Chris Dan el 15 de Jul. de 2020
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..?

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Jul. de 2020
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 comentarios
Walter Roberson
Walter Roberson el 14 de Jul. de 2020
What is the role of your thetha_P matrix in this? Why are you indexing it in your code?
Chris Dan
Chris Dan el 15 de Jul. de 2020
I got it actually, I had to use another variable for integration apart from thetha_P, then it works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by