如何正确地创建用于集成的功能?

6次浏览(过去30天)
Kaleem格雷厄姆
Kaleem格雷厄姆 2021年9月19日
评论道: 明星黾 2021年9月21日
嗨,我试图创建的函数,我可以使用计算一个定积分,这里是函数:
\ \
我要计算的积分
我得到的错误:
我的尝试:
信谊theta_func
Z_func = @(theta_func) exp(1i*pi*cos(theta_func));
E_func = @ (theta_func)罪(theta_func)。* (z_func (theta_func) 1)。* ((z_func (theta_func)。^ 3)1);
E_func = @(theta_func) abs(E_func(theta_func))^2;
expr = @(theta_func) E_func(theta_func).*sin(theta_func);
q = 2 *π* int (expr,θ,0,π);
1评论
1月
1月 2021年9月20日
更喜欢把代码作为文本,而不是截图。
你展示你的方法。它工作吗?我们不能自己尝试,因为这只是一张截图。大多数读者不会花时间再次输入这段代码,主要是因为不清楚这段代码与您的问题有何关联。

登录并发表评论。

答案(1)

明星黾
明星黾 2021年9月20日
发布的代码图像有几个问题。
首先, “z” 在任何地方都没有定义,它不是 “E_func” ,第二个 “E_func” 线应该是:
E_func = @ (theta_func) abs (E_func (theta_func)) ^ 2;
无论如何,可能也没有必要使用符号数学工具箱。
3评论
明星黾
明星黾 2021年9月21日
代码的编写方式意味着Symbolic Math Toolbox函数不合适。
试试这个,
Z_func = @(theta_func) exp(1i*pi*cos(theta_func));
E_func = @ (theta_func)罪(theta_func)。* (z_func (theta_func) 1)。* ((z_func (theta_func)。^ 3)1);
E_func = @ (theta_func) abs (E_func (theta_func)) ^ 2;
expr = @(theta_func) E_func(theta_func).*sin(theta_func);
q = 2 *π*积分(expr 0π)%使用'integral'进行数值积分
q = 20.6011

登录并发表评论。

社区寻宝

在MATLAB中央找到宝藏,发现社区如何可以帮助你!

开始狩猎!