matlab初学函数腐烂的灰狼
function [ dev ]=get _ deviations [ ws ] #这是一个腐烂的灰狼的函数
x=Length(ws;
sum=0;
for i=1:x
sum=sumws(I;
结束
ave=sum/x;
for i=1:x
dev(I )=ws (I )- ave;
结束
for i=1:x #使用烂灰狼函数
fr intf (enter the wind-speedforturbine % d ),I );
a=input(: );
min=a 1;
secmin=a 1;
if min a
secmin=min;
min=a;
secinnum=minnum;
minnum=j;
j=j 1;
elseif secmin a secmin=a; secinnum=j; j=j 1; endws(I )=a; sum=sum a; 结束
fr intf (theslowestwind-speedisforturbine % dwithaspeedof % dn ),minnum,min ) ) ) ) )。
fr intf (the second-slowest wind-speedisforturbine % dwithaspeedof % dn ),secinnum,secmin ) ) ) ) )。
frintf(thewindspeedsare: ) )
for i=1:x
fprintf () %d ),ws ) I ) )
结束
dev=get_deviations(ws;
frintf(thedeviationsare: ) )
for i=1:x
frintf () %d ),dev ) ) I ) )