24小时热门版块排行榜    

查看: 6912  |  回复: 6

Cabird

新虫 (初入文坛)

[求助] Matlab数值积分结果是虚数

小木虫的各位童鞋们,我现在调试matlab程序遇到一个问题。一个很复杂的关于角度theta的数值积分,我调用自带的quadl函数,结果出现虚数。我后来又根据变步长的simpson算法编了一个数值积分程序,结果还是有虚数,而且我的积分程序和quadl算出的结果还有一些误差。积分函数包含了很多三角函数,还有e的指数函数在里面,但是积分过程中并无傅里叶变换等可以带来虚数的过程,不知道虚数是怎么来的。我把积分函数曲线都画出来了,波动比较大,但是作为一个面积,怎么会出现虚数呢?我把我的八个积分函数表达式以及各自的函数曲线贴出来,希望大神们帮我看看,给点意见。论文卡在这里,一直得不到解决。
%========function group of theta=====================
    function F1=Ff1(theta)
%======== basic formula=============================
% TO identify whether the rotating axis is inside the circle
if rrat<=0
    rm=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp((theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp((theta-theta0)*tan(phi)));
else
    rm=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp(-(theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp(-(theta-theta0)*tan(phi)));
end

a=sin(theta0)/sin(theta)-rm;
F1=2*cos(theta)*(((R^2-a^2)^(1/2))*(0.125*R^2*a-0.25*a^3-0.5*a*rm^2+(R^2-a^2)*rm)...
    +(0.5*pi-asin(a/R))*(0.125*R^4+0.5*rm^2*R^2));
    end

    function F2=Ff2(theta)
%========basic formula=============================
% TO identify whether the rotating axis is inside the circle
if rrat<=0
    rm=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp((theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp((theta-theta0)*tan(phi)));
else
rm=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp(-(theta-theta0)*tan(phi)));
R=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp(-(theta-theta0)*tan(phi)));
end
d=sin(betaS+thetah)/sin(betaS+theta)*exp((thetah-theta0)*tan(phi))-rm;
F2=2*cos(theta)*(((R^2-d^2)^(1/2))*(0.125*R^2*d-0.25*d^3-0.5*d*rm^2+(R^2-d^2)*rm)...
    +(0.5*pi-asin(d/R))*(0.125*R^4+0.5*rm^2*R^2));  
    end

    function G1=Gf1(theta)
%========= basic formula=============================
% TO identify whether the rotating axis is inside the circle
if rrat<=0
    rm=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp((theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp((theta-theta0)*tan(phi)));
else
rm=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp(-(theta-theta0)*tan(phi)));
R=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp(-(theta-theta0)*tan(phi)));
end
a=sin(theta0)/sin(theta)-rm;
G1=(rm^2*(R-a)+rm*(R^2-a^2)+(1/3)*(R^3-a^3))*cos(theta);
    end

    function G2=Gf2(theta)
%=========basic formula=============================
% TO identify whether the rotating axis is inside the circle
if rrat<=0
    rm=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp((theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp((theta-theta0)*tan(phi)));
else
rm=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp(-(theta-theta0)*tan(phi)));
R=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp(-(theta-theta0)*tan(phi)));
end
d=sin(betaS+thetah)/sin(betaS+theta)*exp((thetah-theta0)*tan(phi))-rm;
G2=(rm^2*(R-d)+rm*(R^2-d^2)+(1/3)*(R^3-d^3))*cos(theta);  
    end

    function E1=Ef1(theta)
%=========basic formula=============================
% TO identify whether the rotating axis is inside the circle
if rrat<=0
    rm=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp((theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp((theta-theta0)*tan(phi)));
else
rm=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp(-(theta-theta0)*tan(phi)));
R=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp(-(theta-theta0)*tan(phi)));
end
a=sin(theta0)/sin(theta)-rm;
E1=(cos(theta)/(sin(theta))^3)*(R^2-a^2)^(1/2);  
    end

    function E2=Ef2(theta)
%========= basic formula=============================
% TO identify whether the rotating axis is inside the circle
if rrat<=0
    rm=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp((theta-theta0)*tan(phi)));
     R=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp((theta-theta0)*tan(phi)));
else
rm=0.5*(exp((theta-theta0)*tan(phi))+rrat*exp(-(theta-theta0)*tan(phi)));
R=0.5*(exp((theta-theta0)*tan(phi))-rrat*exp(-(theta-theta0)*tan(phi)));
end
d=sin(betaS+thetah)/sin(betaS+theta)*exp((thetah-theta0)*tan(phi))-rm;
E2=cos(theta+betaS)/((sin(theta+betaS))^3)*(R^2-d^2)^(1/2);
    end

    function H1=Hf1(theta)
%===========basic formula=============================
H1=cos(theta)/(sin(theta))^3;
    end

    function H2=Hf2(theta)
%========= basic formula=============================
H2=cos(theta+betaS)/(sin(theta+betaS))^3;
    end
==========computational parameters==================
d2r=pi/180;
theta0=20*d2r;thetah=100*d2r;rrat=0.6;brat=0.5;
betaS=45*d2r; phi=30*d2r;
A1=sin(betaS+thetah)/sin(theta0)*exp((thetah-theta0)*tan(phi));
B1=cos(betaS);
C1=sin(betaS);
thetaB=acot((A1-B1)/C1);
%===========numerical integration for W and D==============

Wd1=quadl(@Ff1,theta0,thetaB);
Wd2=quadl(@Ff2,thetaB,thetah);
Wd=Wd1+Wd2;

Wp1=quadl(@Gf1,theta0,thetaB);
Wp2=quadl(@Gf2,thetaB,thetah);
Wp=Wp1+Wp2;

Kd1=quadl(@Ef1,theta0,thetaB);
Kd2=quadl(@Ef2,thetaB,thetah);
Dd=-2*cot(phi)*(sin(theta0))^2*Kd1...
    -2*cot(phi)*exp(2*(thetah-theta0)*tan(phi))*(sin(thetah+betaS))^2*Kd2;

Kp1=quadl(@Hf1,theta0,thetaB);
Kp2=quadl(@Hf2,thetaB,thetah);
Dp=-cot(phi)*(sin(theta0))^2*Kp1...
    -cot(phi)*exp(2*(thetah-theta0)*tan(phi))*(sin(thetah+betaS))^2*Kp2;

disp('[Wd1,Wd2,Wp1,Wp2,Kd1,Kd2,Kp1,Kp2]=');
disp([Wd1,Wd2,Wp1,Wp2,Kd1,Kd2,Kp1,Kp2]');

八个被积函数曲线.jpg
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

solar0913

至尊木虫 (著名写手)

【答案】应助回帖

感谢参与,应助指数 +1
问题出在开根号里,根号下的值为负数,所以导致有虚数。

[ 发自手机版 http://muchong.com/3g ]
2楼2013-03-21 00:09:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

Cabird

新虫 (初入文坛)

引用回帖:
2楼: Originally posted by solar0913 at 2013-03-21 00:09:03
问题出在开根号里,根号下的值为负数,所以导致有虚数。

很多天没上木虫,才看到你的回复。发帖的第二天帮师兄调程序发现根号问题反应过来了,忘记删帖了。
3楼2013-04-08 16:59:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyp0901911

新虫 (初入文坛)

您好!问题解决了吗?我也遇到同样的困难
4楼2013-04-08 17:00:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

匿名

用户注销 (正式写手)

本帖仅楼主可见
5楼2013-04-08 23:02:32
已阅   申请EPI   回复此楼   编辑   查看我的主页

左思之一

铁虫 (小有名气)

用dde23求解时滞微分方程,没有负数开放方情况,出现虚数解,怎么回事?
今天天是蓝的
6楼2015-04-17 10:52:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

左思之一

铁虫 (小有名气)

引用回帖:
4楼: Originally posted by gyp0901911 at 2013-04-08 17:00:46
您好!问题解决了吗?我也遇到同样的困难

您的问题解决了吗?用dde23求解时滞微分方程,没有负数开放方情况,出现虚数解,合理吗?
今天天是蓝的
7楼2015-04-17 10:53:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 Cabird 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[论文投稿] 申请回稿延期一个月,编辑同意了。但系统上的时间没变,给编辑又写邮件了,没回复 10+3 wangf9518 2026-03-17 4/200 2026-03-19 23:55 by babero
[考研] 一志愿中国海洋大学,生物学,301分,求调剂 +5 1孙悟空 2026-03-17 6/300 2026-03-19 23:46 by zcl123
[考研] 0817 化学工程 299分求调剂 有科研经历 有二区文章 +18 rare12345 2026-03-18 18/900 2026-03-19 22:36 by 学员8dgXkO
[考博] 东华理工大学化材专业26届硕士博士申请 +8 zlingli 2026-03-13 8/400 2026-03-19 16:32 by 轻松不少随
[考研] 招收调剂硕士 +4 lidianxing 2026-03-19 10/500 2026-03-19 16:05 by 余麟余
[考研] 一志愿福大288有机化学,求调剂 +3 小木虫200408204 2026-03-18 3/150 2026-03-19 13:31 by houyaoxu
[考研] 材料080500调剂求收留 +4 一颗meteor 2026-03-13 4/200 2026-03-19 10:32 by 30660438
[考研] 311求调剂 +4 冬十三 2026-03-18 4/200 2026-03-18 21:47 by 尽舜尧1
[考研] 26调剂/材料/英一数二/总分289/已过A区线 +7 步川酷紫123 2026-03-13 7/350 2026-03-18 17:12 by 尽舜尧1
[考研] 302求调剂 +10 呼呼呼。。。。 2026-03-17 10/500 2026-03-18 12:45 by Linda Hu
[考研] 312求调剂 +8 陌宸希 2026-03-16 9/450 2026-03-18 12:39 by Linda Hu
[考博] 环境领域全国重点实验室招收博士1-2名 +3 QGZDSYS 2026-03-13 5/250 2026-03-18 11:13 by QGZDSYS
[考研] 303求调剂 +4 睿08 2026-03-17 6/300 2026-03-18 11:01 by Iveryant
[硕博家园] 湖北工业大学 生命科学与健康学院-课题组招收2026级食品/生物方向硕士 +3 1喜春8 2026-03-17 5/250 2026-03-17 17:18 by ber川cool子
[考研] 有没有道铁/土木的想调剂南林,给自己招师弟中~ +3 TqlXswl 2026-03-16 7/350 2026-03-17 15:23 by TqlXswl
[考博] 26申博 +4 八6八68 2026-03-16 4/200 2026-03-17 13:00 by 轻松不少随
[考研] 304求调剂 +3 曼殊2266 2026-03-14 3/150 2026-03-16 16:39 by houyaoxu
[考研] 求老师收留调剂 +4 jiang姜66 2026-03-14 5/250 2026-03-15 20:11 by Winj1e
[考研] 复试调剂 +3 呼呼?~+123456 2026-03-14 3/150 2026-03-14 16:53 by WTUChen
[考研] 266求调剂 +4 学员97LZgn 2026-03-13 4/200 2026-03-14 08:37 by zhukairuo
信息提示
请填处理意见