找回密码
 注册
Simdroid-非首页
查看: 75|回复: 1

求助ga函数的问题:如何传递不需要优化的参数

[复制链接]
发表于 2011-3-3 08:07:07 | 显示全部楼层 |阅读模式 来自 江苏南京
如何传递不需要优化的参数:比如  function   f=clg(s0,p1,p2,p3),其中s0是需要优化的参数,p1,p2,p3是不需要优化的参数,但是是需要传递到函数中的参数。用ga函数时怎么处理这个问题,小弟新手,求助。
发表于 2011-3-3 09:03:19 | 显示全部楼层 来自 河北廊坊
Simdroid开发平台
  1. function [x,fval,exitflag,output,population,score] = test20110303(nvars)
  2. % This is an auto generated MATLAB file from Optimization Tool.

  3. % Start with the default options
  4. options = gaoptimset;
  5. % Modify options setting
  6. options = gaoptimset(options,'Display', 'off');
  7. [x,fval,exitflag,output,population,score] = ...
  8. ga(@(x)myfun(x,1),nvars,[],[],[],[],[],[],[],options);
复制代码
上述程序中函数
  1. function y=myfun(x,a)
  2. % written by BB
  3. y=x^2+a;
复制代码
希望对你有所帮助

评分

1

查看全部评分

回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Simapps系列直播

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-10-6 13:20 , Processed in 0.033018 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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