急急!!求助matlab高手
这是一个遗传算法的一部分,在程序运行后,出现:??? Error: File: D:\MATLAB6p5\work\Untitled2.m Line: 1Column: 1Missing variable or function.
不知道为什么。这是在网上直接下载的程序,据说是matlab。还有,哪位高手会编写基于遗传算法排的课表的matlab程序?我初学matlab,很多不懂。
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<alloc.h>
#include<conio.h>
#include<float.h>
#include<time.h>
#include<graphics.h>
#include<bios.h>
#define maxpop 100
#define maxstring 100
struct pp{unsigned char chrom;
float x,fitness;
unsigned int parent1,parent2,xsite;
};
struct pp *oldpop,*newpop,*p1;
unsigned int popsize,lchrom,gem,maxgen,co_min,jrand;
unsigned int nmutation,ncross,jcross,maxpp,minpp,maxxy;
float pcross,pmutation,sumfitness,avg,max,min,seed,maxold,oldrand;
unsigned char x,y;
float *dd,ff,maxdd,refpd,fm;
FILE *fp,*fp1;
float objfunc(float);
void statistics();
int select();
int flip(float);
int crossover();
void generation();
void initialize();
void report();
float decode();
void crtinit();
void inversion();
float random1();
void randomize1();
main()
{unsigned int gen,k,j,tt;
char fname;
float ttt;
clrscr();
co_min=0;
if((oldpop=(struct pp *)farmalloc(maxpop*sizeof(struct pp)))==NULL)
{printf("memory requst fail!\n");exit(0);}
if((dd=(float *)farmalloc(maxstring*maxstring*sizeof(float)))==NULL)
{printf("memory requst fail!\n");exit(0);}
if((newpop=(struct pp *)farmalloc(maxpop*sizeof(struct pp)))==NULL)
{printf("memory requst fail!\n");exit(0);}
if((p1=(struct pp *)farmalloc(sizeof(struct pp)))==NULL)
{printf("memory requst fail!\n");exit(0);}
for(k=0;k<maxpop;k++) oldpop.chrom='{MAIN_FORM}';
for(k=0;k<maxpop;k++) newpop.chrom='{MAIN_FORM}';
printf("Enter Result Data Filename:");
gets(fname);
if((fp=fopen(fname,"w+"))==NULL)
{printf("cannot open file\n");exit(0);} 这个是c++程序啦
页:
[1]