First input argument must be a function handle
조회 수: 12 (최근 30일)
이전 댓글 표시
Hello, Please!!!!! i need help. I'm trying to solve an integral function :
r=0:0.02:0.2;
d=[0.0005;0.001;0.0015;0.002;0.0025;0.003;0.0035;0.004;0.0045;0.005;0.0055];
fun={@(d,r) d.^3*exp(-4.1*(r.^(-0.21)*d))};
F=integral(fun,0.0005,0.0055);
But it returns : "First input argument must be a function handle"
Please how can i solve this problem?
댓글 수: 0
답변 (2개)
the cyclist
2014년 9월 13일
편집: the cyclist
2014년 9월 13일
There were a couple problems here.
First, you put your function in side a cell array (with the curly brackets), which is unnecessary, and is why MATLAB did not recognize fun as a function handle.
Second, you seem to want to do a double integral, but you used integral() rather than integral2().
Third, your function definition used matrix multiplication rather than element-wise multiplication in a couple places.
The following code fixes all of these problems, but I can't say for sure is what you intended to do:
fun=@(d,r) d.^3.*exp(-4.1.*(r.^(-0.21).*d));
F=integral2(fun,0.0005,0.0055,0,0.2);
Note that your pre-definition of r and d vectors is going to be ignored by integral2(). These two lines will execute on their own.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!