关于matlab无法调用mapminmax解决办法

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

关于matlab系列无法调用mapminmax函数的解决方法matlab7.0/7.1以及以下版本的函数库中没有mapminmax函数,所以编程调用这个函数时会提示未定义该函数,查了写资料,但是网友回答的太不靠谱了,我自己做了下总结,方法如下:1.matlab升级到7.8或者以上版本,这些版本的matlab中自带有mapminmax函数,可以直接调用。2.不想升级的话,我们就要自己写mapminmax函数了,这里我提供mapminmax函数的源程序如下:function[out1,out2]=mapminmax(in1,in2,in3,in4)%MPMINMAXMapmatrixrowminimumandmaximumvaluesto[-11].%%Syntax%%[y,ps]=mapminmax(x,ymin,ymax)%[y,ps]=mapminmax(x,fp)%y=mapminmax('apply',x,ps)%x=mapminmax('reverse',y,ps)%dx_dy=mapminmax('dx',x,y,ps)%dx_dy=mapminmax('dx',x,[],ps)%name=mapminmax('name');%fp=mapminmax('pdefaults');%names=mapminmax('pnames');%mapminmax('pcheck',fp);%%Description%%MAPMINMAXprocessesmatricesbynormalizingtheminimumandmaximumvalues%ofeachrowto[YMIN,YMAX].%%MAPMINMAX(X,YMIN,YMAX)takesXandoptionalparameters,%X-NxQmatrixora1xTSrowcellarrayofNxQmatrices.%YMIN-MinimumvalueforeachrowofY.(Defaultis-1)%YMAX-MaximumvalueforeachrowofY.(Defaultis+1)%andreturns,%Y-EachMxQmatrix(whereM==N)(optional).%PS-Processsettings,toallowconsistentprocessingofvalues.%%MAPMINMAX(X,FP)takesparametersasstruct:FP.ymin,FP.ymax.%MAPMINMAX('apply',X,PS)returnsY,givenXandsettingsPS.%MAPMINMAX('reverse',Y,PS)returnsX,givenYandsettingsPS.%MAPMINMAX('dx',X,Y,PS)returnsMxNxQderivativeofYw/respecttoX.%MAPMINMAX('dx',X,[],PS)returnsthederivative,lessefficiently.%MAPMINMAX('name')returnsthenameofthisprocessmethod.%MAPMINMAX('pdefaults')returnsdefaultprocessparameterstructure.%MAPMINMAX('pdesc')returnstheprocessparameterdescriptions.%MAPMINMAX('pcheck',fp)throwsanerrorifanyparameterisillegal.%%Examples%%Hereishowtoformatamatrixsothattheminimumandmaximum%valuesofeachrowaremappedtodefaultinterval[-1,+1].%%x1=[124;111;322;000]%[y1,ps]=mapminmax(x1)%%Next,weapplythesameprocessingsettingstonewvalues.%%x2=[523;111;673;000]%y2=mapminmax('apply',x2,ps)%%Herewereversetheprocessingofy1togetx1again.%%x1_again=mapminmax('reverse',y1,ps)%%Algorithm%%ItisassumedthatXhasonlyfiniterealvalues,andthat%theelementsofeachrowarenotallequal.%%y=(ymax-ymin)*(x-xmin)/(xmax-xmin)+ymin;%%SeealsoFIXUNKNOWNS,MAPSTD,PROCESSPCA,REMOVECONSTANTROWS%Copyright1992-2006TheMathWorks,Inc.%$Revision:1.1.6.6$%Processfunctionboilerplatescriptboiler_process%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Namefunctionn=namen='MapMinimumandMaximum';%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ParameterDefaultsfunctionfp=param_defaults(values)iflength(values)=1,fp.ymin=values{1};elsefp.ymin=-1;endiflength(values)=2,fp.ymax=values{2};elsefp.ymax=fp.ymin+2;end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ParameterNamesfunctionnames=param_names()names={'MininumvalueforeachrowofY.','MaximumvalueforeachrowofY.'};%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ParameterCheckfunctionerr=param_check(fp)mn=fp.ymin;mx=fp.ymax;if~isa(mn,'double')||any(size(mn)~=[11])||~isreal(mn)||~isfinite(mn)err='yminmustbearealscalarvalue.';elseif~isa(mx,'double')||any(size(mx)~=[11])||~isreal(mx)||~isfinite(mx)||(mx=mn)err='ymaxmustbearealscalarvaluegreaterthanymin.';elseerr='';end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%NewProcessfunction[y,ps]=new_process(x,fp)ifany(any(~isfinite(x)))error('UseFIXUNKNOWNStoreplaceNaNvaluesinX.');endps.name='mapminmax';ps.xrows=size(x,1);ps.yrows=ps.xrows;ps.xmax=max(x,[],2);ps.xmin=min(x,[],2);ps.ymax=fp.ymax;ps.ymin=fp.ymin;ifany(ps.xmax==ps.xmin)warning('UseREMOVECONSTANTROWStoremoverowswithconstantvalues.');endy=apply_process(x,ps);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ApplyProcessfunctiony=apply_process(x,ps)Q=size(x,2);oneQ=ones(1,Q);rangex=ps.xmax-ps.xmin;rangex(rangex==0)=1;%Avoiddivisionsbyzerorangey=ps.ymax-ps.ymin;y=rangey*(x-ps.xmin(:,oneQ))./rangex(:,oneQ)+ps.ymin;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ReverseProcessfunctionx=reverse_process(y,ps)Q=size(y,2);oneQ=ones(1,Q);rangex=ps.xmax-ps.xmin;rangey=ps.ymax-ps.ymin;x=rangex(:,oneQ).*(y-ps.ymin)*(1/rangey)+ps.xmin(:,oneQ);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%DerivativeofYw/respecttoXfunctiondy_dx=derivative(x,y,ps);Q=size(x,2);rangex=ps.xmax-ps.xmin;rangey=ps.ymax-ps.ymin;d=diag(rangey./rangex);dy_dx=d(:,:,ones(1,Q));复制以上代码,在matlab中生成M文件,文件名取为mapminmax.m,然后放到currentDirectory路径中的work文件夹里面(这是我的工作空间),你们也可以放到自己的工作空间文件夹里面,这还没完,编译程序是还会提示木有boiler_process函数的提示,boiler_process函数源程序如下:%PROCESSFUNCTIONBOILERPLATECODE%Copyright2005-2007TheMathWorks,Inc.%TODO-AddsizecheckingforXandYif(nargin1),error('NNET:Arguments','Notenougharguments.');endifisstr(in1)switchlower(in1)case'name',ifnargin1,error('NNET:Arguments','Toomanyinputargumentsfor''name''action'),endif(nargout1),error('NNET:Arguments','Toomanyoutputargumentsfor''name''action'),endout1=name;case'pdefaults'ifnargin2,error('NNET:Arguments','Toomanyinputargumentsfor''pdefaults''action'),endifnargin2,in2={};endif(nargout1),error('NNET:Arguments','Toomanyoutputargumentsfor''pdefaults''action'),endout1=param_defaults(in2);case'pnames'ifnargin1,error('NNET:Arguments','Toomanyinputargumentsfor''pnames''action'),endif(nargout1),error('NNET:Arguments','Toomanyoutputargumentsfor''pnames''action'),endout1=param_names;case'pcheck'if(nargin2),err

1 / 8
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功