double integral with one variable

3 visualizaciones (últimos 30 días)
Ozan
Ozan el 26 de Nov. de 2012
Hi, I have been struggling to understand below double integral phenomenon. I am trying to solve an loop problem and in one small part of loop I need to take an definite double integral. If the formula contains two variables, I can get the correct answer. But, if the formula has just one variable (as shown below) I get the below error. How can I handle this problem?
Here is my simplified code;
syms x y;
A2=y^3;
f= matlabFunction(A2);
integrand = @(x,y)f(x,y);
Q2 = quad2d(integrand,-1,1,-1,1);
And the error I get from Matlab is below:
??? Error using ==> sym.matlabFunction>@(y)y.^3
Too many input arguments.
Error in ==> @(x,y)f(x,y)
Error in ==> quad2d>tensor at 355
Z = FUN(X,Y); NFE = NFE + 1;
Error in ==> quad2d at 169
[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in ==> example at 7
Q2 = quad2d(integrand,-1,1,-1,1);
I would appreciate any help, idea, thought...

Respuesta aceptada

Walter Roberson
Walter Roberson el 26 de Nov. de 2012
matlabFunction() by default creates a function handle that expects only as many input parameters as there are free variables in the symbolic function. You should specifically tell matlabFunction() which variables you wish to have in the calling sequence and in which order.

Más respuestas (1)

Ozan
Ozan el 28 de Nov. de 2012
Thank you for your answer Mr.Roberson. How can I handle my code? I mean, which changes I need to do to solve this issue?

Categorías

Más información sobre Loops and Conditional Statements 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