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

답변 (1개)

Walter Roberson
Walter Roberson 2013년 2월 14일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Function Creation에 대해 자세히 알아보기

질문:

2013년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by