声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2763|回复: 4

[综合讨论] "feval" method?

[复制链接]
发表于 2007-4-13 15:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我在算一个弹性力学问题,算出结果后要求能表现变化特征的一些点
我使用了fminsearch来找极小值,结果给我报错

Error using ==> fcnchk
If FUN is a MATLAB object, it must have an feval method.

Error in ==> C:\MATLAB6p5\toolbox\matlab\funfun\fminsearch.m
On line 110  ==> funfcn = fcnchk(funfcn,length(varargin));

头痛中。。。程序附上

clear
syms A B C D K a b E v w u h Q0 f;
D=E*h^3/(12*(1-v^2))
A=-Q0*b^3*(3+v+2*(1+v)*log(b/a)+a^2*(1-v)/b^2)/(8*D*(b^2+a^2+(b^2-a^2)*v))
B=Q0*b/(4*D)
C=-(2*A+B)*a^2
K=-A*a^2
/*以上为参数
/*下面是函数
w=A*b^2+B*b^2*log(b/a)+C*log(b/a)+K
u=(b^3+a^2*b)/(2*E*a*(a^2+b^2))
f=w/u
/*求极小值
a0=[0,100]
a=fminsearch(f,a0)
回复
分享到:

使用道具 举报

发表于 2007-4-13 15:55 | 显示全部楼层
原帖由 1020810611 于 2007-4-13 15:07 发表
我在算一个弹性力学问题,算出结果后要求能表现变化特征的一些点
我使用了fminsearch来找极小值,结果给我报错

Error using ==> fcnchk
If FUN is a MATLAB object, it must have an feval method.

...


建议多看matlab帮助:


Example 1. A classic test example for multidimensional minimization is the Rosenbrock banana function  
The minimum is at (1,1) and has the value 0. The traditional starting point is (-1.2,1). The anonymous function shown here defines the function and returns a function handle called banana:
banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2;

Pass the function handle to fminsearch:
[x,fval] = fminsearch(banana,[-1.2, 1])

This produces
x =
    1.0000    1.0000
fval =
    8.1777e-010
发表于 2007-4-13 16:00 | 显示全部楼层
f里面这么多参数,怎么能求最小值
 楼主| 发表于 2007-4-13 17:34 | 显示全部楼层
不能算极小值啊?
那用plot画 ‘f’与‘b’的关系,大侠知道怎么改吗?我试了下
把除b以外的变量全都附了值,是不是要把运算符全改成数组的运算符啊
发表于 2007-4-13 20:28 | 显示全部楼层
function f=myfun(b,a,E,v,h,Q0)
D=E*h^3/(12*(1-v^2));
A=-Q0*b^3*(3+v+2*(1+v)*log(b/a)+a^2*(1-v)/b^2)/(8*D*(b^2+a^2+(b^2-a^2)*v));
B=Q0*b/(4*D);
C=-(2*A+B)*a^2;
K=-A*a^2;
w=A*b^2+B*b^2*log(b/a)+C*log(b/a)+K;
u=(b^3+a^2*b)/(2*E*a*(a^2+b^2));
f=w/u;


>> a=fminsearch(@(b) myfun(b,1,2,3,4,5),3)

a =

  7.3242e-005

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-14 10:20 , Processed in 0.060249 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表