error of inline function

In this
Sa=[1 2];
Si =[2 3;45;6 7;8 9;15;5 7];
function='exp(-Theta.*(Si(i,:)-Sa));
I want to find the double integration of this function. IN this I_whole is one arrray of NX2 array.
MY code is :
Theta=[18 3.5];
[x,y]=size(I_whole);
for i=1:1:x
for j=1:1:y
Si(i,j)=I_whole(i,j);
temp=inline('exp(-Theta.*(Si(i,:)-Sa))');
f(i,:)=temp;
end
end
Energy=dblquad(f,1,x,1,y);
But I am getting below error:
??? Error using ==> inline.subsref at 14
Not enough inputs to inline function.
Error in ==> dblquad>innerintegral at 73
fcl = intfcn(xmin, y(1), varargin{:}); %evaluate
only to get the class below
Error in ==> quad at 76
y = f(x, varargin{:});
Error in ==> dblquad at 53
Q = quadf(@innerintegral, ymin, ymax, tol, trace,
intfcn, ...

Respuestas (1)

Walter Roberson
Walter Roberson el 14 de Feb. de 2013

0 votos

Do not use inline for that.
I would suggest using anonymous functions, but since all of your expression components have defined values, you have no variable to integrate with respect to. Are you sure you want quadrature integration (which requires a function to integrate) and not the two-dimensional equivalent of trapz() ?

3 comentarios

Mona
Mona el 15 de Feb. de 2013
Thank u so much... Act i am new in Matlab can u suggest me what should I change in above code???
Mona
Mona el 15 de Feb. de 2013
And I want quadrature integration (which requires a function to integrate).
Walter Roberson
Walter Roberson el 15 de Feb. de 2013
Editada: Walter Roberson el 15 de Feb. de 2013
If you want quadrature integration, you need a function with a free variable to integrate over -- the variable of integration. What is the variable of integration in your expression
exp(-Theta.*(Si(i,:)-Sa))
You have defined specific values for Theta, Si, and Sa, and you are in a "for" loop that defines "i".

Iniciar sesión para comentar.

Categorías

Más información sobre Function Creation en Centro de ayuda y File Exchange.

Preguntada:

el 14 de Feb. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by