首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么没有足够的投入?

为什么没有足够的投入?
EN

Stack Overflow用户
提问于 2015-04-20 05:05:24
回答 1查看 42关注 0票数 1

我有两个职能:

代码语言:javascript
复制
function y=Fun(x)
7*x^4+exp(-7*x)-5*x-11

代码语言:javascript
复制
function Xs = secantroot(Fun,x1,x2,imax)
% SecantRoot finds theroot of Fun=0 using the secant
% Input variables:
% Fun   Name of a user-defined function that calculates Fun for a given x.
% x1,x2 Two points in the neighborhood of the root (on either side or the
%       same side of the root
% Err   Relative error.
% imax  Maximum number of iterations
% Output variable:
% Xs    Solution
xi(1)=x1;%sets the initial values of x1,the value to the right of the true root
xi(2)=x2;%sets the initial values of x2, the value to the left of the true root
for i=3:imax
xi(i)=x2-feval(Fun,x2)*(x1-x2)/(feval(Fun,x1)-feval(Fun,x2));
x1=x2;
x2=xi(i);
end
Xs=xi

但是当我进入

代码语言:javascript
复制
>>>secantroot(Fun,2.5,0.7,10)

我收到错误使用的乐趣(第2行),没有足够的输入参数。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-20 05:14:32

尝试传递一个函数句柄,而不是:

代码语言:javascript
复制
>>> secantroot(@Fun,2.5,0.7,10)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29739659

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档