Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2009-05-20
年龄: 39
帖子: 4
声望力: 0 ![]() |
![]()
我在求三次B样条曲线外一已知点坐标的点到样条曲线的最短距离时调用了ga函数,程序如下:
i=1; for m=up_m:1:down_m k=1; for d=0:0.01:0.3 j=1; cun_mindis(i,j)=0; for n=up_n:1:down_n %在一行上的每一点计算它到B样条曲线的最小值 x=Hx(m,n); z=Hz(m,n); [a fval]=ga(@dis,1); cun_mindis(i,j)=fval; j=j+1; end min_dis(i,k)=min(cun_mindis(i, ![]() k=k+1; end Rafa(i)=sum(mis_dis(i, ![]() i=i+1; end function y=dis(x,z,u) y=((x-0.36109998859720*u^3+3.25*u^2+8.875*u+21.00003998767780)^2+(z-1.71245000056680*u^3-1.4971*u^2-1.361*u+1.89996746693460)^2)^(1/2); 出现以下错误提示: ??? Error using ==> gads\private\makeState GA cannot continue because user supplied fitness function failed with the following error: Input argument "u" is undefined. Error in ==> gads\private\gaunc at 65 state = makeState(GenomeLength,FitnessFcn,options); Error in ==> ga at 260 [x,fval,exitFlag,output,population,scores] = gaunc(FUN,GenomeLength,options); Error in ==> draw_simulate at 61 [a fval]=ga(@dis,1); x和z值不知道能不能读进去,这两个值是已知的,郁闷啊,那位高手指点一二,不胜感激! |
![]() |
![]() |
![]() |
#2 |
初级会员
注册日期: 2009-05-20
年龄: 39
帖子: 4
声望力: 0 ![]() |
![]()
其中那个笑脸应该是:
|
![]() |
![]() |
![]() |
#3 |
初级会员
注册日期: 2009-05-20
年龄: 39
帖子: 4
声望力: 0 ![]() |
![]()
我怎样才能向ga的适应度函数里边传值,[a fval]=ga(@dis,1);
dis函数里边有四个参数,只有一个是变量,其他的三个参数如何送进去? |
![]() |
![]() |