欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    matlab 常用算法大全.docx

    • 资源ID:1942820       资源大小:22.38KB        全文页数:23页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    matlab 常用算法大全.docx

    1、matlab 常用算法大全Matlab 高级算法程序代码汇总一、灰色预测模型matlab程序% renkou1=renkou(:,1);%年末常住人口数 % renkou2=renkou(:,2);%户籍人口% renkou3=renkou(:,3);%非户籍人口% shjian=1979:2010; %以上数据自己给x0=renkou2;n=length(x0);lamda=x0(1:n-1)./x0(2:n)range=minmax(lamda)x1=cumsum(x0)for i=2:nz(i)=0.5*(x1(i)+x1(i-1);endB=-z(2:n),ones(n-1,1);Y=

    2、x0(2:n);u=BYx=dsolve(Dx+a*x=b,x(0)=x0);x=subs(x,a,b,x0,u(1),u(2),x1(1);yuce1=subs(x,t,0:n-1);digits(6),y=vpa(x) %为提高预测精度,先计算预测值,再显示微分方程的解yuce=x0(1),diff(yuce1)epsilon=x0-yuce %计算残差delta=abs(epsilon./x0) %计算相对误差rho=1-(1-0.5*u(1)/(1+0.5*u(1)*lamda %计算级比偏差值%以深圳人口数据得到预测模型及预测误差相关数据 lamda = Columns 1 thro

    3、ugh 8 0.9741 0.9611 0.9419 0.8749 0.9311 0.9093 0.9302 0.9254 Columns 9 through 16 0.9245 0.9278 0.9442 0.9376 0.9127 0.9148 0.9332 0.9477 Columns 17 through 24 0.9592 0.9445 0.9551 0.9562 0.9594 0.9461 0.9469 0.9239 Columns 25 through 31 0.9140 0.9077 0.9243 0.9268 0.9312 0.9446 0.9618 range = 0.87

    4、49 0.9741 x1 = 1.0e+003 * Columns 1 through 8 0.0313 0.0634 0.0967 0.1322 0.1727 0.2162 0.2641 0.3155 Columns 9 through 16 0.3711 0.4313 0.4961 0.5647 0.6380 0.7182 0.8059 0.8999 Columns 17 through 24 0.9990 1.1024 1.2119 1.3265 1.4463 1.5712 1.7033 1.8427 Columns 25 through 32 1.9936 2.1588 2.3407

    5、2.5375 2.7499 2.9780 3.2194 3.4705 u = -0.0665 31.3737 y = -472.117+503.377*exp(.664533e-1*t)yuce = Columns 1 through 8 31.2600 34.5876 36.9641 39.5040 42.2183 45.1192 48.2194 51.5326 Columns 9 through 16 55.0734 58.8576 62.9017 67.2238 71.8428 76.7792 82.0548 87.6928 Columns 17 through 24 93.7183 1

    6、00.1578 107.0397 114.3945 122.2547 130.6550 139.6324 149.2267 Columns 25 through 32 159.4802 170.4382 182.1492 194.6649 208.0405 222.3352 237.6121 253.9386 epsilon = Columns 1 through 8 0 -2.4976 -3.5741 -4.0540 -1.6983 -1.5992 -0.3594 -0.0826 Columns 9 through 16 0.5266 1.2824 1.9183 1.4262 1.3772

    7、3.4408 5.6352 6.2772 Columns 17 through 24 5.4417 3.2222 2.4203 0.2055 -2.4047 -5.7350 -7.5924 -9.7767 Columns 25 through 32 -8.5502 -5.3082 -0.2192 2.1651 4.3395 5.7348 3.8379 -2.9086 delta = Columns 1 through 8 0 0.0778 0.1070 0.1144 0.0419 0.0367 0.0075 0.0016 Columns 9 through 16 0.0095 0.0213 0

    8、.0296 0.0208 0.0188 0.0429 0.0643 0.0668 Columns 17 through 24 0.0549 0.0312 0.0221 0.0018 0.0201 0.0459 0.0575 0.0701 Columns 25 through 32 0.0567 0.0321 0.0012 0.0110 0.0204 0.0251 0.0159 0.0116 rho = Columns 1 through 8 -0.0411 -0.0271 -0.0066 0.0650 0.0049 0.0282 0.0058 0.0110 Columns 9 through

    9、16 0.0119 0.0084 -0.0091 -0.0020 0.0245 0.0223 0.0027 -0.0128 Columns 17 through 24 -0.0251 -0.0094 -0.0208 -0.0219 -0.0254 -0.0111 -0.0119 0.0126 Columns 25 through 31 0.0232 0.0300 0.0122 0.0095 0.0048 -0.0095 -0.0280二、遗传算法程序代码% Optimizing a function using Simple Genetic Algorithm with elitist pre

    10、served%Max f(x1,x2)=100*(x1*x1-x2).2+(1-x1).2; -2.0480=x1,x2=bestvbestv=fmax;%到目前为止最优适应度值bvalxx=bval(indmax,:);%到目前为止最佳位串optxx=xx(indmax,:);%到目前为止最优参数end Bfit1(ii)=bestv; % 存储每代的最优适应度%遗传操作开始%轮盘赌选择for i=1:(N-1)r=rand;tmp=find(r=q);newbval(i,:)=bval(tmp(1),:);end newbval(N,:)=bvalxx;%最优保留bval=newbval;

    11、%单点交叉for i=1:2:(N-1)cc=rand;if ccpcpoint=ceil(rand*(2*L-1);%取得一个1到2L-1的整数ch=bval(i,:);bval(i,point+1:2*L)=bval(i+1,point+1:2*L);bval(i+1,point+1:2*L)=ch(1,point+1:2*L);endend bval(N,:)=bvalxx;%最优保留%位点变异mm=rand(N,2*L)p_best_fitness(count_x)p_best_fitness(count_x) = current_fitness(count_x);for count_

    12、y = 1:dimensionsp_best(count_x,count_y) = particle_position(count_x,count_y);endendend%decide on the global best among all the particlesg_best_val,g_best_index = max(current_fitness);%g_best contains the position of teh global bestfor count_y = 1:dimensionsg_best(count_y) = particle_position(g_best_

    13、index,count_y);end%update the position and velocity compponentsfor count_x = 1:no_of_particlesfor count_y = 1:dimensionsp_current(count_y) = particle_position(count_x,count_y);endfor count_y = 1:dimensionsparticle_velocity(count_y) = particle_velocity(count_y) + c1*rand*(p_best(count_y)-p_current(co

    14、unt_y) + c2*rand*(g_best(count_y)-p_current(count_y);particle_positon(count_x,count_y) = p_current(count_y) +particle_velocity(count_y);endendendg_bestcurrent_fitness(g_best_index)clear all, clc % pso exampleiter = 1000; % number of algorithm iterationsnp = 2; % number of model parametersns = 10; %

    15、number of sets of model parametersWmax = 0.9; % maximum inertial weightWmin = 0.4; % minimum inertial weightc1 = 2.0; % parameter in PSO methodologyc2 = 2.0; % parameter in PSO methodologyPmax = 10 10; % maximum model parameter valuePmin = -10 -10; % minimum model parameter valueVmax = 1 1; % maximu

    16、m change in model parameterVmin = -1 -1; % minimum change in model parametermodelparameters(1:np,1:ns) = 0; % set all model parameter estimates for all model parameter sets to zeromodelparameterchanges(1:np,1:ns) = 0; % set all change in model parameter estimates for all model parameter sets to zero

    17、bestmodelparameters(1:np,1:ns) = 0; % set best model parameter estimates for all model parameter sets to zerosetbestcostfunction(1:ns) = 1e6; % set best cost function of each model parameter set to a large numberglobalbestparameters(1:np) = 0; % set best model parameter values for all model paramete

    18、r sets to zerobestparameters = globalbestparameters; % best model parameter values for all model parameter sets (to plot)globalbestcostfunction = 1e6; % set best cost function for all model parameter sets to a large numberi = 0; % indicates ith algorithm iterationj = 0; % indicates jth set of model

    19、parametersk = 0; % indicates kth model parameterfor k = 1:np % initializationfor j = 1:nsmodelparameters(k,j) = (Pmax(k)-Pmin(k)*rand(1) + Pmin(k); % randomly distribute model parametersmodelparameterchanges(k,j) = (Vmax(k)-Vmin(k)*rand(1) + Vmin(k); % randomly distribute change in model parameterse

    20、ndendfor i = 2:iterfor j = 1:nsx = modelparameters(:,j);% calculate cost functioncostfunction = 105*(x(2)-x(1)2)2 + (1-x(1)2;if costfunction =T_min iter_num=1; s_num=1; plot(T,totaldis1,r.) hold on while iter_numiter_max&s_nums_max; order2=exhgpath(order1); %随机交换两个城市位置 totaldis2=distance(address,ord

    21、er2); R=rand; DeltaDis=totaldis2-totaldis1; %新的距离-原来的距离 if DeltaDisR)%本算法最核心的思想:以一定概率接受坏的结果,防止局部最优 order1=order2; totaldis1=totaldis2; else s_num=s_num+1; end iter_num=iter_num+1; end T=T*0.99; end set(gca,xscale,log);%或者使用semilogx,有相同效果 xlabel(退火温度);ylabel(总距离); order1 totaldis1 figure(3) plot(address(order1,1


    注意事项

    本文(matlab 常用算法大全.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开