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!