I just want to know the reason why the integral function doesn't work this way?
12 ビュー (過去 30 日間)
古いコメントを表示
Harsha vardhan naidu
2020 年 4 月 15 日
コメント済み: Steven Lord
2020 年 4 月 15 日
%p is a function handle so what's the problem.
Now i am working on finding response of the rectangular plate. So, after solving I get a function as an output and I gotta integrate that function between a certain interval to find a constant. So let us assume f is the function i got as an output. If i give f as an input to integral function I am geting an error saying "FUNCTION PASSED TO INTEGRAL FUNCTION MUST BE A FUNCTION HANDLE" so i created another variable p and made it a function handle now i am getting an error saying "INPUT FUNCTION MUST RETURN SINGLE OR DOUBLE VALUES. FOUND SYM". Looking for someone's help. Any way to solve this issue?
syms x;
f= x^2;
p = @(x) f;
q = integral(p,0,1)
0 件のコメント
採用された回答
Bjorn Gustavsson
2020 年 4 月 15 日
You have to convert the symbolic function to a function-handle that returns a scalar double. You can do this for your example problem:
F = matlabFunction(f);
q = integral(F,0,1);
The first step converts the symbolic expression into a matlab-function-handle.
HTH
1 件のコメント
Steven Lord
2020 年 4 月 15 日
Another alternative, if you want to perform the integration symbolically, would be to call the int function instead of integral. The signature is slightly different (you need to specify the variable over which you're integrating) but they're still quite similar.
syms x
f = x^2;
int(f, x, 0, 1)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Special Values についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!