Using integral to define a function
1 回表示 (過去 30 日間)
古いコメントを表示
So I'm trying to define a function which has an integral inside.
Below is a simplified version of the function with the same error message: Unrecognized function or variable 'E'.
What I don't get is since variable E goes away after integral, shouldn't there be no reason for me to define it?
Also, how could this problem be resolved?
Thanks in advance.
result(0)
function test_integral = result(V)
test_integral = integral( @temp, E, -1, 1);
function tempf = temp(E)
tempf = E.*V;
end
end
0 件のコメント
採用された回答
Dyuman Joshi
2023 年 11 月 24 日
編集済み: Dyuman Joshi
2023 年 11 月 24 日
Remove the E from the integral() call, as it is not required.
result(2)
result(4)
result(6)
function test_integral = result(V)
test_integral = integral(@temp, -1, 1);
function tempf = temp(E)
tempf = E.*V;
end
end
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!