回 帖 发 新 帖 刷新版面

主题:菜鸟请教

请教各位。
我想求一个函数的解
比如 F(x)=cos(x)*2+sin(x) -r =0;
我知道fsolve
可以,但是如果其中的r如果是外界输入的值,那该怎么写这个程序阿。
就是说我外界输入一个r的值,就给出一个x的值。谢谢[em13]

回复列表 (共1个回复)

沙发


function x=examplesolve(r)
% to slove the question
%
% input : r
%
% output: x1

x0=0;%这儿可能要根据具体情况
x=fsolve(@(x)(cos(x)*2+sin(x)-r),x0);
x

我来回复

您尚未登录,请登录后再回复。点此登录或注册