如果在matlab中出现Undefined function 'initializega' for input arguments of type 'double'怎么解决

如果在matlab中出现Undefined function 'initializega' for input arguments of type 'double'怎么解决,第1张

楼主是不是参考的别人的程序,initializega这个子函数在你的电脑中并不存在

可能是matlab版本问题,matlab7以上的版本中没有initializega函数了,全都集合到gaoptimset函数中。

旧版本中的initializega函数:

function [pop] = initializega(num, bounds, evalFN,evalOps,options)

% function [pop]=initializega(populationSize, variableBounds,evalFN,

% evalOps,options)

% initializega creates a matrix of random numbers with

% a number of rows equal to the populationSize and a number

% columns equal to the number of rows in bounds plus 1 for

% the f(x) value which is found by applying the evalFN

% This is used by the ga to create the population if it

% is not supplied

%

% pop - the initial, evaluated, random population

% populatoinSize - the size of the population, ie the number to create

% variableBounds - a matrix which contains the bounds of each variable, ie

% [var1_high var1_low; var2_high var2_low; ]

% evalFN - the evaluation fn, usually the name of the m file for

% evaluation

% evalOps - any options to be passed to the eval function defaults []

% options - options to the initialize function, ie

% [type prec] where eps is the epsilon value

% and the second option is 1 for float and 0 for binary,

% prec is the precision of the variables defaults [1e-6 1]

% Binary and Real-Valued Simulation Evolution for Matlab GAOT V2

% Copyright (C) 1998 CR Houck, JA Joines, MG Kay

%

% CR Houck, JJoines, and MKay A genetic algorithm for function

% optimization: A Matlab implementation ACM Transactions on Mathmatical

%

% This program is free software; you can redistribute it and/or modify

% it under the terms of the GNU General Public License as published by

% the Free Software Foundation; either version 1, or (at your option)

% any later version

%

% This program is distributed in the hope that it will be useful,

% but WITHOUT ANY WARRANTY; without even the implied warranty of

% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the

% GNU General Public License for more details A copy of the GNU

% General Public License can be obtained from the

% Free Software Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, USA

if nargin<5

options=[1e-6 1];

end

if nargin<4

evalOps=[];

end

if any(evalFN<48) %Not a m file

if options(2)==1 %Float GA

estr=['x=pop(i,1); pop(i,xZomeLength)=', evalFN ';'];

else %Binary GA

estr=['x=b2f(pop(i,:),bounds,bits); pop(i,xZomeLength)=', evalFN ';'];

end

else %A m file

if options(2)==1 %Float GA

estr=['[ pop(i,:) pop(i,xZomeLength)]=' evalFN '(pop(i,:),[0 evalOps]);'];

else %Binary GA

estr=['x=b2f(pop(i,:),bounds,bits);[x v]=' evalFN

'(x,[0 evalOps]); pop(i,:)=[f2b(x,bounds,bits) v];'];

end

end

numVars = size(bounds,1); %Number of variables

rng = (bounds(:,2)-bounds(:,1))'; %The variable ranges'

if options(2)==1 %Float GA

xZomeLength = numVars+1; %Length of string is numVar + fit

pop = zeros(num,xZomeLength); %Allocate the new population

pop(:,1:numVars)=(ones(num,1)rng)(rand(num,numVars))+

(ones(num,1)bounds(:,1)');

else %Binary GA

bits=calcbits(bounds,options(1));

xZomeLength = sum(bits)+1; %Length of string is numVar + fit

pop = round(rand(num,sum(bits)+1));

end

for i=1:num

eval(estr);

end

Systemoutprint("请输入折扣:");

zeko=scannernextDouble();

  zekoh=zekouqianzeko;

你之前只是将单个商品的账单打印出来了,但是没有将账单总值加在一起,因此zekouqian变量还是o,你需要在将代码顺序改一下

package text1;

import javautilScanner;

public class nidechao1 {

public static void main(String args[]){

double DTVqian=30;   //T恤单价

double Dpaiqian=248;  //网球拍单价

double Dxieqian=150;  //网球鞋单价

double STVqian=0;     //T恤总价

double Sxieqian=0;    //网球鞋总价

double Spaiqian=0;    //网球拍总价

int tvnum=0;     //T恤数量

int painum=0;   //网球拍数量

int xienum=0;   // 网球鞋数量

double zekouqian=0;// 折扣前总价

double zeko=00;   //折扣后总价

double  zekoh=0;   //折扣

double fk=0;      //付款

double zl=0;      //找零

Scanner scanner =new Scanner(Systemin);

Systemoutprintln("请输入购买T恤数量:");

tvnum = scannernextInt();

Systemoutprintln("请输入购买网球拍数量:");

   painum=scannernextInt();

Systemoutprintln("请输入购买网球鞋数量:");

xienum=scannernextInt();

STVqian=tvnumDTVqian;

Spaiqian=painumDpaiqian;

Sxieqian=xienumDxieqian;

zekouqian=STVqian+Spaiqian+Sxieqian;

       Systemoutprintln("消费单据");

Systemoutprintln("消费单");

Systemoutprintln("购买商品\t单价\t数量\t金额");

Systemoutprintln("T恤:\t"+DTVqian+"\t"+tvnum+"\t"+STVqian);

Systemoutprintln("网球拍:\t"+Dpaiqian+"\t"+painum+"\t"+Spaiqian);

Systemoutprintln("网球鞋:\t"+Dxieqian+"\t"+xienum+"\t"+Sxieqian);

Systemoutprint("请输入折扣:");

zeko=scannernextDouble();

  zekoh=zekouqianzeko;

Systemoutprintln("总金额:"+ zekoh);

        Systemoutprintln("付款:");

fk=scannernextDouble();

       Systemoutprintln("找零:"+(fk-zekoh));

}

}

#include "stdafxh"

#include "iostream"

#include "mathh"

using namespace std;

int _tmain(int argc, _TCHAR argv[])

{

double x = 11;

while(fabs(5xxx-3xx+2x-8)>0000001)

x = x - (5xxx-3xx+2x-8)/(15xx-6x+2);

cout<<"方程的解为"<<x<<endl;

system("pause");

return 0;

}

 

重点改动:

scanf("%lf,%lf",&x1,&x2);

#include <stdioh>

#include <mathh>

int main()

{ double calculate(double y1,double y2,double fy1,double fy2);

  double x1,x2,fx1,fx2;

  double a;

  printf("enter x1 & x2:");

  scanf("%lf,%lf",&x1,&x2);

  fx1=(((x1+3)x1-8)x1+12)x1-10;

  fx2=(((x2+3)x2-8)x2+12)x2-10;

  printf("%f %f %f %f\n",x1,x2,fx1,fx2);

  a=calculate(x1,x2,fx1,fx2);

  printf("x=%lf\n",a);

  return 0;

}

double calculate(double y1,double y2,double fy1,double fy2)

{ double fy0,y0;

  double a;

  y0=(y1+y2)/2;

  fy0=(((y0+3)y0-8)y0+12)y0-10;

  printf("%f ",y0);

  if(fabs(fy0)>=1e-10)

  { if ((fy0fy1)<0)

    { y2=y0;

      fy2=fy0;

    }

    else

    { y1=y0;

      fy1=fy0;

    }

    a=calculate(y1,y2,fy1,fy2);

  }

  else

  { a=y0;

    printf("%62f",a);

  }

  return(a);

}

1、直接用数转换到字符串的方法即可。sprintf(s,"%lf",a);s是字符数组,a是double。这样就把a写到s中了。

2、例程:

#include<stdioh>

#include<iostream>

using namespace std;

int main()

{

char s[12];

double a=123456789876;

sprintf(s,"%lf",a);

printf("%s",s);

return 0;

}

1、在打开的ie浏览器窗口右上方点击齿轮图标,选择“Internet选项”,如下图所示:

2、在打开的Internet选项窗口中,切换到安全栏,在安全选卡中点击“自定义级别”,如下图所示:

3、在“安全设置-Internet 区域”界面找到“Java 小程序脚本”、“活动脚本”,并将这两个选项都选择为“禁用”,然后点击确定,如下图所示:

// 根据直线方程的一般式Ax+By+C=0,点到直线的距离公式:d=(Ax0+By0+C)/sqrt(AA+BB)推断出垂足的计算公式

double da = y3-y2;

double db = x2-x3;

double dc = x3y2-x2y3;

dx = ( dbdbx1 - dadby1 - dadc ) / ( dada + dbdb );

dy = ( -dadbx1 + daday1 - dbdc ) / ( dada + dbdb );

double ea = y3-y1;

double eb = x1-x3;

double ec = x3y1-x1y3;

ex = ( ebebx2 - eaeby2 - eaec ) / ( eaea + ebeb );

ey = ( -eaebx2 + eaeay2 - ebec ) / ( eaea + ebeb );

double fa = y1-y2;

double fb = x2-x1;

double fc = x1y2-x2y1;

fx = ( fbfbx3 - fafby3 - fafc ) / ( fafa + fbfb );

fy = ( -fafbx3 + fafay3 - fbfc ) / ( fafa + fbfb );

cout << "顶点A至BC边的垂足D(" << dx << "," << dy << "),AD = " << AD << endl;

cout << "顶点B至AC边的垂足E(" << ex << "," << ey << "),BE = " << BE << endl;

cout << "顶点C至AB边的垂足F(" << fx << "," << fy << "),CF = " << CF << endl;

欢迎分享,转载请注明来源:品搜搜测评网

原文地址:https://pinsoso.cn/meirong/2313922.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-11-25
下一篇2023-11-25

随机推荐

  • 抗老精华液哪个牌子最好用

    抗老精华液以下牌子最好用:1、宝丽极光幻彩精华液这款产品是它抗衰老系列当中最高端的产品,里面蕴含的成分也是非常的珍贵的,集合了多种核心专利技术,可以从根源上柔弱肌肤。2、莱伯妮鱼子酱反重力精华这款产品主要利用了深海鱼籽精粹作为配方,再结合珍

    2024-04-15
    62000
  • 妮维雅控油保湿啫喱和欧莱雅控油保湿啫哩

    控油效果来说绝对是妮维雅的。欧莱雅的效果还不如UNO的那款乳液。不过要是让我来说,我还是最喜欢UNO的,是最舒服的一款,性价比极高。其实控油这种东西,你都不能指望太长时间。我们都是天生的这种体制啊。就算是控油比较不错的妮维雅的,比其他的好,

    2024-04-15
    55500
  • nivea妮维雅水感防晒乳真假辨别对比图

    nivea妮维雅水感防晒乳我是代购买的,担心自己买到了假货,想学习下如何分辨真假。那么nivea妮维雅水感防晒乳真假怎么辨别下面我为你提供妮维雅防晒乳对比图。真假辨别瓶身正面:正品的瓶身正面下方是有一行日文文字的,而假货的该位置却是

    2024-04-15
    47400
  • 黑洞的意思黑洞的意思是什么

    灵魂学,宇宙篇:灵魂黑洞场论序言: 这篇是以宇宙黑洞为核心,来思索灵魂视界的可能性。  通过黑洞的视界理论,衍生出了灵魂学的一些模块思想,真实视界和灵魂视界,也是实体理论和虚体理论的细化。 万物非实即虚。  能改变和扩大世界观宇宙观的,只有

    2024-04-15
    40600
  • 12岁女孩能使用妮维雅的丝柔美白爽肤水或丝润爽肤水吗?

    12岁女孩能使用妮维雅的丝柔美白爽肤水或丝润爽肤水吗?这是许多家长和女孩们关心的问题。我们需要知道妮维雅的丝柔美白爽肤水和丝润爽肤水都是针对成年人的产品。这些产品中可能含有一些成分,如酒精或其他化学物质,对于12岁的女孩来说可能会过于刺激。

    2024-04-15
    39700
  • 这几件SK-ii使用的先后顺序

    上面回答的不对,清莹露最先使用,因为它相当于水。神仙水使用之前必须用水垫底的,要不然会干。用完清莹露再用神仙水。然后是眼霜,然后是精华露。因为精华是帮助吸收之后的乳液的,最后是乳液。sk2使用顺序和方法:步骤一、洁颜产品首先我们可以使用sk

    2024-04-15
    50100
  • sk2小灯泡怎么样?

    sk2小灯泡很多人听到这个名字会觉得很好奇,sk2小灯泡样子确实有点像灯泡,一般的人都知道sk2这个品牌,sk2是日本一个很高端的品牌,sk2小灯泡虽然价格贵,但是确实好用,用过之后皮肤会变得很光滑,那k2小灯泡怎么样?sk2小灯泡好用吗?

    2024-04-15
    45300

发表评论

登录后才能评论
保存