风力发电机功率曲线统计MATLAB代码实现.docx
风力发电机功率曲线统计MATLAB代码实现functionwindspeed_avractive_power_devwindspeed_fin_avractive_power_fin_avrCP=Powercurve-caLv03(filenamelzfilename2Jilename3zfilename4)%读取excel的xls×文件%B列为功率C列为风速datal=xlsread(filenamelzlz,B2C52000');data2=xlsread(filename2zlz,B2C52000');data3=xlsread(filename3zl'B2C52000');data4=xlsread(filename4zl'B2C52000,);%将四个Excel表合成一个表格data=datal;data2;data3;data4;%对数据进行筛选风速<3ms功率COkw的数据不要n=length(data(z2);forj=l:l:nifdata(j,2)>=3&&data(j,l)>=ldata-opt(jzl)=data(jz2);data_opt(j,2)=data(j,l);endend%对风速和功率进行排序并返回索引%求0.5ms的时间间隔的平均风速和相对应的平均功率,标准差m=length(ind);k=O;u=0;h=0;windspeed_sum=O;active_power_sum=0;windspeed_avr=O;active_power_avr=0;active_power_error_sum=0;windspeed_fin_sum=O;active_power_fin_sum=0;P=1.062;A=pi*(882)2;forwindspeed_num=3:0.5:19.5fori=l:l:m%初步计算平均风速和平均功率active_power(i)=data_opt(ind(i),2);ifwindspeed(i)>=windspeed-num&&windspeed(i)<windspeed-num+0.5k=k+l;windspeed-sum=windspeed_sum+windspeed(i);active_power_sum=active_power_sum+active_power(i);endq=(windspeed_num-3)/0.5+l;windspeed_avr(q)=windspeed_sum/k;active_power_avr(q)=active_power_sum/k;%计算标准差ifwindspeed(i)>=windspeed-num&&windspeed(i)<windspeed-num+0.5h=h+l;active_power_error(i)=(active_power(i)-active_power_avr(q)A2;active_power_error_sum=active_power_error_sum+active_power_error(i);endactive_power_dev(q)=sqrt(active_power_error_sum/h);%剔除散点和平均功率差的绝对值与标准差比值大于4的点,并计算最终的平均风速/功率曲线/发电机功率系数ifwindspeed(i)>=windspeed-num&&windspeed(i)<windspeed-num+O.5e=abs(active_power(i)-active_power_avr(q)/active_power_dev(q);ife<=4u=u+l;windspeed_fin_sum=windspeed_fin_sum+windspeed(i);active_power_fin_sum=active_power_fin_sum+active_power(i);endendwindspeed_fin_avr(q)=windspeed_fin_sum/u;active_power_fin_avr(q)=active_power_fin_sum/u;%计算发电机功率系数CP(q)=1000*active_power_fin_avr(q)/(0.5*P*A*(windspeed_fin_avr(q)A3);endwindspeed_sum=O;active_power_sum=0;active_power_error_sum=0;windspeed_fin_sum=O;active_power_fin_sum=0;k=0;h=O;u=O;end%画出初步平均风速和平均功率的曲线figureplot(windspeed_avr,active_power_avr,'rset(gca,xtick,0:1:20)set(gca/ytick0:100:1600)gridonxlabel(,windspeed-avrms')ylabel('active_power_avr(kW)')title(,powercurve')%画出标准差的曲线figureplot(windspeed_avrzactive_power_dev/g%bar(2*windspeed_num+0.5)/2,active_power_dev);set(gcaxtick,0lr20)set(gca/ytick0:20:200)gridon×label('windspeed-avrms,)ylabel('active_power_dev')title('powerstandarddeviation')%画出最终的平均风速和平均功率曲线figureplot(windspeed_fin_avr,active_power_fin_avr/kset(gca/xtick',O:l:2O)set(gca/ytick0:100:1600)gridonxlabel('windspeed_fin_avrms,)ylabel('active_power_fin_avr(kW)')title('finalpowercurve')%画出最终的发电机功率系数figureplot(windspeed-fin-avrzCPmset(gca/xtick',O:l:2O)set(gca,'ytick,0:0.1:0.6)gridonxlabel('windspeed_fin_avrms,)ylabel('active_power_dev')title('CP系数)%画出采集的散点图figureplot(data(rz2)zdata(:,1)/'.');set(gcaz'xtick,0:1:22)set(gcaz,ytick,0:100:1600)gridon×label(,windspeedms')ylabel(,active-power,)title('powerpoint')