error of inline function
5 views (last 30 days)
Show older comments
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, ...
0 Comments
Answers (1)
Walter Roberson
on 14 Feb 2013
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 Comments
Walter Roberson
on 15 Feb 2013
Edited: Walter Roberson
on 15 Feb 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".
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!