"feval" method?
我在算一个弹性力学问题,算出结果后要求能表现变化特征的一些点我使用了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=
a=fminsearch(f,a0) 原帖由 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:
= fminsearch(banana,[-1.2, 1])
This produces
x =
1.0000 1.0000
fval =
8.1777e-010 f里面这么多参数,怎么能求最小值 不能算极小值啊?
那用plot画 ‘f’与‘b’的关系,大侠知道怎么改吗?我试了下
把除b以外的变量全都附了值,是不是要把运算符全改成数组的运算符啊 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]