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, ...

Réponses (1)

Walter Roberson
Walter Roberson le 14 Fév 2013

0 votes

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 commentaires

Mona
Mona le 15 Fév 2013
Thank u so much... Act i am new in Matlab can u suggest me what should I change in above code???
Mona
Mona le 15 Fév 2013
And I want quadrature integration (which requires a function to integrate).
Walter Roberson
Walter Roberson le 15 Fév 2013
Modifié(e) : Walter Roberson le 15 Fév 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".

Connectez-vous pour commenter.

Catégories

En savoir plus sur Function Creation dans Centre d'aide et File Exchange

Question posée :

le 14 Fév 2013

Community Treasure Hunt

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

Start Hunting!

Translated by