24小时热门版块排行榜    

查看: 2542  |  回复: 15

yan_fei

银虫 (小有名气)

[求助] 各位朋友,如何用matlab编写这个方程,并求解?

各位朋友,最近遇到这么一个方程,不知道如何用matlab解决,方程如下:
公式中的未知数是t,其他的都是已知的。怎么用matlab编写这个方程,并求解?请各位朋友帮忙,谢谢!

方程
回复此楼

» 收录本帖的淘帖专辑推荐

学习知识

» 猜你喜欢

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

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

yan_fei

银虫 (小有名气)

没有朋友回复啊,是金币少吗?小弟金币有限,是每天辛苦签到积攒的,再追加100个金币,请知道的朋友帮忙,怎么用matlab编程把这个方程解出来,公式求和符号上面的【】是取整数的意思。
2楼2012-07-30 20:39:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ...
感谢参与,应助指数 +1
xiegangmai: 金币+3, 谢谢应助! 2012-07-30 21:50:21
yan_fei: 金币+130, 感谢这位朋友的回复,金币全部给你!不过不知道为什么初值不同,结果差别很大,我想只改变alph的值求相应的t,随便一个初值都能求出准确的解,如知道望告知!感谢您的帮助~~~ 2012-07-30 22:39:56
CODE:
function yan
global s phi lam alpha
s=3.2;
phi=1;
lam=3;
alpha=0.6;
[X,FVAL,EXITFLAG,OUTPUT]=fsolve(@sumt,10)

function y=sumt(t)
global s phi lam alpha
y=0;
for N=0:floor(s*t-phi)
    y=y+exp(-lam*t)*(lam*t)^N/gamma(N+1);
end
y=y-alpha;

Equation solved.

fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.




X =

   10.0881


FVAL =

-9.6716e-010


EXITFLAG =

     1


OUTPUT =

       iterations: 2
        funcCount: 6
        algorithm: 'trust-region dogleg'
    firstorderopt: 2.0551e-010
          message: [1x695 char]
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
3楼2012-07-30 21:09:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★
xiegangmai: 金币+2, 专家考核, 辛苦了! 2012-07-30 21:50:33
或者这么写也可以
function yan
global s phi lam alpha
s=3.2;
phi=1;
lam=3;
alpha=0.6;
[X,FVAL,EXITFLAG,OUTPUT]=fsolve(@sumt,10)

function y=sumt(t)
global s phi lam alpha
y=0;
% for N=0:floor(s*t-phi)
%     y=y+exp(-lam*t)*(lam*t)^N/gamma(N+1);
% end
N=0:floor(s*t-phi);
yN=exp(-lam*t)*(lam*t).^N./gamma(N+1);
y=sum(yN);
y=y-alpha;
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
4楼2012-07-30 21:15:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yan_fei

银虫 (小有名气)

引用回帖:
4楼: Originally posted by dbb627 at 2012-07-30 21:15:00
或者这么写也可以
function yan
global s phi lam alpha
s=3.2;
phi=1;
lam=3;
alpha=0.6;
=fsolve(@sumt,10)

function y=sumt(t)
global s phi lam alpha
y=0;
% for N=0:floor(s*t-phi)
%     y=y+ ...

首先感谢您的回复,我刚试了下您的程序,好像对初始值的依赖性很强,没次给不同的初始值求的结果都不一样,而且结果几乎和给的初始值差不多。我是想改变不同的alpha的值求出对应的t. 程序运行后的提示为:

No solution found.

fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance squared, but the vector of function values
is not near zero as measured by the default value of the function tolerance.



fsolve stopped because the relative norm of the current step, 4.694166e-013, is less than
max(options.TolX^2,eps) = 1.000000e-012. However, the sum of squared function values,
r = 9.759502e-003, exceeds sqrt(options.TolFun) = 1.000000e-003.

Optimization Metric                                               Options
relative norm(step) =  4.69e-013                max(TolX^2,eps) =  1e-012 (default)
r =  9.76e-003                                    sqrt(TolFun) = 1.0e-003 (default)


fsolve stopped because the relative norm of the current step, 4.694166e-013, is less than
max(options.TolX^2,eps) = 1.000000e-012. However, the sum of squared function values,
r = 9.759502e-003, exceeds sqrt(options.TolFun) = 1.000000e-003.

Optimization Metric                                               Options
relative norm(step) =  4.69e-013                max(TolX^2,eps) =  1e-012 (default)
r =  9.76e-003                                    sqrt(TolFun) = 1.0e-003 (default)
5楼2012-07-30 21:53:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

★ ★
xiegangmai: 金币+2, 专家考核, 辛苦了! 2012-08-02 23:03:57
能给下参数吗,有可能alpha值不合适,你可以看下这个例子随t的改变 alpha是收敛的
function yan
global s phi lam alpha
s=3.2;
phi=1;
lam=3;
alpha=0.6;
%[X,FVAL,EXITFLAG,OUTPUT]=fsolve(@sumt,10)
t=0.1:1:10000;
for i=1:length(t)
    ya(i)=sumt(t(i));
end
plot(t,ya,'*-')
   
   

function y=sumt(t)
global s phi lam alpha
y=0;
N=0:floor(s*t-phi);
yN= poisspdf(N,lam*t);
y=sum(yN);
y=y-alpha;


The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
6楼2012-07-30 22:59:15
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yan_fei

银虫 (小有名气)

引用回帖:
6楼: Originally posted by dbb627 at 2012-07-30 22:59:15
能给下参数吗,有可能alpha值不合适,你可以看下这个例子随t的改变 alpha是收敛的
function yan
global s phi lam alpha
s=3.2;
phi=1;
lam=3;
alpha=0.6;
%=fsolve(@sumt,10)
t=0.1:1:10000;
for i=1:len ...

原始数据是这样的:phi=9;lam=0.1389;alpha=0,7%,21%,38%,54%,68%,78%,86%91%,94%,97%;
phi和lam值不变,alpha依次取0~97%对应计算出t的值是:t<20,t=21,t=23;t=25;t=27;t=29;t=31;t=33;t=35;t=37;t=39.
7楼2012-07-31 08:27:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

引用回帖:
7楼: Originally posted by yan_fei at 2012-07-31 08:27:41
原始数据是这样的:phi=9;lam=0.1389;alpha=0,7%,21%,38%,54%,68%,78%,86%91%,94%,97%;
phi和lam值不变,alpha依次取0~97%对应计算出t的值是:t<20,t=21,t=23;t=25;t=27;t=29;t=31;t=33;t=35;t=37;t=39....

s的取值是多少呢?,如果alpha依次取0~97%对应计算出t的值是:t<20,t=21,t=23;t=25;t=27;t=29;t=31;t=33;t=35;t=37;t=39,那么计算结果应该不会解不出来
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
8楼2012-07-31 08:52:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yan_fei

银虫 (小有名气)

引用回帖:
8楼: Originally posted by dbb627 at 2012-07-31 08:52:14
s的取值是多少呢?,如果alpha依次取0~97%对应计算出t的值是:t<20,t=21,t=23;t=25;t=27;t=29;t=31;t=33;t=35;t=37;t=39,那么计算结果应该不会解不出来...

不好意思忘了写s的值了,s=0.5.
9楼2012-07-31 08:55:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

★ ★
xiegangmai: 金币+2, 谢谢参与! 2012-08-02 23:04:08
这个确实要估计下t,可以做图估计
function yan
global s phi lam alpha
s=0.5;
phi=9;
lam=0.1389;
A=[0,0.07,0.21,0.38,0.54,0.68,0.78,0.86 0.91,0.94,0.97];
for i=1:11
   alpha=A(i) ;
[X(i),FVAL(i),EXITFLAG,OUTPUT]=fsolve(@sumt,16+i*1.9);
end
X
FVAL
t=0.1:0.1:50;
for i=1:length(t)
    ya(i)=sumt(t(i))+alpha;
end
plot(t,ya,'-')
hold on;plot(X,A,'ro')
   
   

function y=sumt(t)
global s phi lam alpha
y=0;
% for N=0:floor(s*t-phi)
%     y=y+exp(-lam*t)*(lam*t)^N/gamma(N+1);
% end
N=0:floor(s*t-phi);
yN=poisspdf(N,lam*t);
y=sum(yN)-alpha;
%y=y-alpha;
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
10楼2012-07-31 09:27:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 yan_fei 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 面上意见出来了 +12 黄鸟于飞Chao 2026-08-29 21/1050 2026-08-31 18:04 by 异氰酸酯
[基金申请] 中青基了要发朋友圈吗? +7 349506619 2026-08-28 7/350 2026-08-31 13:39 by 冼亮淀粉酶
[基金申请] 投票:  有多少人是今天查系统知道结果的? +17 爱看书的可乐 2026-08-26 19/950 2026-08-31 11:51 by xiangy672
[考博] 找导师 +6 yuanjiabao 2026-08-29 7/350 2026-08-30 14:40 by 生科新手
[基金申请] 我就是申请一个面上项目而已,这评审意见是按照杰青的条件评的吧? +6 gouxfjh 2026-08-28 11/550 2026-08-30 07:57 by gouxfjh
[基金申请] 国自然评审意见 +13 wangmingqi 2026-08-28 19/950 2026-08-29 10:22 by Poppy1104
[基金申请] 2026年叶企孙基金 +4 bud_bud 2026-08-27 7/350 2026-08-29 07:23 by foolishmani
[基金申请] 系统查不到 +11 董八千 2026-08-26 11/550 2026-08-28 18:06 by Leogzhya
[基金申请] 基金系统什么内容也没有 30+4 winsaint 2026-08-27 9/450 2026-08-28 11:06 by maolC
[基金申请] 怎么查啊 +6 huang1991js 2026-08-26 6/300 2026-08-28 08:42 by winsaint
[基金申请] 哪位高人中了,把查询到的截图贴出来让我看看,让我长长见识 +5 yuleib84 2026-08-26 6/300 2026-08-28 00:02 by yudaoqian88
[基金申请] 基金未中,这种答复是模板吗? +5 zhaosm1982 2026-08-27 6/300 2026-08-27 16:00 by lfy8008
[基金申请] 为什么 国际(地区)合作与交流项目 没有放榜? 10+3 majunge000 2026-08-26 11/550 2026-08-27 08:42 by 北京莱茵编辑
[基金申请] 我不理解! +15 Edward_pc 2026-08-26 23/1150 2026-08-26 20:34 by zzuzxg
[基金申请] 为什么国自然不能直接公布 +4 bjdxyxy 2026-08-26 4/200 2026-08-26 13:12 by qingmu1201
[基金申请] 国际合作可查了,中了面上 (EPI+1)(金币+50) +18 Ldrop2023 2026-08-26 18/900 2026-08-26 11:15 by cmrandy
[基金申请] 项目信息和经费信息在系统里都可以看到了 +6 wittyboy 2026-08-26 14/700 2026-08-26 10:55 by wittyboy
[基金申请] 国合可查了 +3 paperzjh 2026-08-26 3/150 2026-08-26 10:41 by LemmonTr
[基金申请] 今天务委会开完了,明天出结果吗 +19 angus9576 2026-08-25 23/1150 2026-08-26 10:03 by zp519
[基金申请] 在坚冰还盖着北海的时候,我看到了怒放的梅花。 (金币+10) +6 ziyangfang 2026-08-25 9/450 2026-08-25 20:26 by huagongfeihu
信息提示
请填处理意见