如果在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

随机推荐

  • 贴牌代加工化妆品商标注册需要哪几类

    商标分类:化妆品行业应该注册哪些类别的商标      尽管面临国内经济增长与零售环境的不确定性,国内化妆品市场仍然保持超越整体可选消费的增速。新冠疫情在带来风险的同时也带来了机遇,在疫情冲击下部分国际化妆品集团业绩亏损较大,但同时一部分国际

    2024-04-15
    34800
  • 妈妈用的护肤品|后天气丹

    针对妈妈们用的护肤品做了个推荐,价位大概是200-600左右,这段时间有好多小仙女私信咨询我,不同肤质以及不同价位的后-津率享套盒后-津率享套盒:抗皱首选,这个系列有淡淡的人参味,滋润不油腻,清爽不干燥,适合30岁以上的干性混干肌肤,改善

    2024-04-15
    27500
  • 欧诗漫珍珠白套装适合什么年纪_适合肤质

    你只知道自己黑,却不知道为何会黑,都说一白遮百丑,一黑毁所有。珍珠白系列产品,均持有国家特证,有美白特证才敢说美白。下面我带大家来看一下欧诗漫珍珠白套装适合什么年纪_适合肤质。欧诗漫珍珠白套装适合什么年纪欧诗漫OSM新珍珠白补水美白

    2024-04-15
    26900
  • 我想给我妈妈买眼部精华或者眼霜,我想知道哪个牌子适合她,他接近50岁了,想去眼纹,黑眼圈

    选择眼部精华或眼霜的品牌和类型需要考虑许多因素,包括你的妈妈的肤质、需求、预算和个人偏好。以下是一些适合成熟肌肤的眼部护肤品牌和产品的推荐:1 La Mer眼部精华霜:这是一款轻盈的眼部精华霜,可显著减少细纹和皱纹,同时提供深层保湿。2 E

    2024-04-15
    14300
  • 时光润颜发光水好用吗

    题主是否想询问“萱郦冻龄时光润颜发光水好用吗”?好用。萱郦冻龄时光润颜发光水,利用纤连蛋白成分的强大修护再生作用,加速细胞生长,强化角质层,能够有效提升肌肤弹性值,恢复年轻健康态,为皮肤补充流失的水分和支撑肌肤的胶原蛋白,起到基底修护的效果

    2024-04-15
    22900
  • 后的套盒哪个系列的最好?有什么区别吗?

    在韩妆界摸爬滚打多年,whoo的套盒也了解了不少。Whoo的套盒有很多系列,以天气丹,拱辰享,津率享三个系列为主推,在韩妆界是有很高的口碑的。下面我就来跟说说,这三个系列的区别在哪吧。1、天气丹天气丹这个系列的套盒主推的是修复肌肤,平衡脸部

    2024-04-15
    10300
  • 什么男士洗面奶让你觉得很好用呢?谈谈你的经验

    第一款芙丽芳丝洗面奶是在某猫忍痛割爱花了一百多买的,就是跟风,想体验一下高端产品的感觉芙丽芳丝洗面奶使用了椰油酰甘氨酸钾作为主要的清洁成分,能够清除面部的污垢、部分彩妆以及防水型的防晒。 洗面奶中还加入了一些植物成分,有保湿和舒缓作用,在脸

    2024-04-15
    11700

发表评论

登录后才能评论
保存