24小时热门版块排行榜    

CyRhmU.jpeg
查看: 2051  |  回复: 15
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

yan_fei

银虫 (小有名气)

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

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

方程
回复此楼

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

学习知识

» 猜你喜欢

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

已阅   回复此楼   关注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的回帖
查看全部 16 个回答

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的回帖

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的回帖
信息提示
请填处理意见