前31项(傅里叶,沃什,U系统,哈尔,V系统)分解重构对比
非连续正交函数系下基函数的问题,这段代码仅做了前31项的
%MUST%Edward.Xu%2012/11/26%%%K=0,K=1%U system,V system比较%%clear all;close all;%%%figure;%%x=0:0.01:1;z1=random('Normal',0,1,1,length(x));z1=z1*40.*(x<0.5)+0.*(x>=0.5);x2=0:1:length(x)-1;z2= x2.^2 - x2;z3=square(0.1.*x2,50);z4=sin(0.5.*x2);%z=z1 or z2 or z3 or z4z=z2;subplot(3,5,1);plot(x,z,'r');%axis([0,1,-1.5,1.5]);xlabel('原函数');grid on;subplot(3,5,2);plot(x,z,'r');%axis([0,1,-1.5,1.5]);xlabel('原函数');grid on;subplot(3,5,3);plot(x,z,'r');%axis([0,1,-1.5,1.5]);xlabel('原函数');grid on;subplot(3,5,4);plot(x,z,'r');%axis([0,1,-1.5,1.5]);xlabel('原函数');grid on;subplot(3,5,5);plot(x,z,'r');%axis([0,1,-1.5,1.5]);xlabel('原函数');grid on;%%fun=@(x) (1/(sqrt(2.*3.14))).*(x>=0 & x<=1);y=fun(x);total0=0;for i=1:1:length(x) total0 = total0 + y(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(x).*(x>=0 & x<=1);y1=fun(x);total1=0;for i=1:1:length(x) total1 = total1 + y1(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(x).*(x>=0 & x<=1);y2=fun(x);total2=0;for i=1:1:length(x) total2 = total2 + y2(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(2.*x).*(x>=0 & x<=1);y3=fun(x);total3=0;for i=1:1:length(x) total3 = total3 + y3(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(2.*x).*(x>=0 & x<=1);y4=fun(x);total4=0;for i=1:1:length(x) total4 = total4 + y4(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(3.*x).*(x>=0 & x<=1);y5=fun(x);total5=0;for i=1:1:length(x) total5 = total5 + y5(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(3.*x).*(x>=0 & x<=1);y6=fun(x);total6=0;for i=1:1:length(x) total6 = total6 + y6(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(4.*x).*(x>=0 & x<=1);y7=fun(x);total7=0;for i=1:1:length(x) total7 = total7 + y7(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(4.*x).*(x>=0 & x<=1);y8=fun(x);total8=0;for i=1:1:length(x) total8 = total8 + y8(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(5.*x).*(x>=0 & x<=1);y9=fun(x);total9=0;for i=1:1:length(x) total9 = total9 + y9(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(5.*x).*(x>=0 & x<=1);y10=fun(x);total10=0;for i=1:1:length(x) total10 = total10 + y10(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(6.*x).*(x>=0 & x<=1);y11=fun(x);total11=0;for i=1:1:length(x) total11 = total11 + y11(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(6.*x).*(x>=0 & x<=1);y12=fun(x);total12=0;for i=1:1:length(x) total12 = total12 + y12(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(7.*x).*(x>=0 & x<=1);y13=fun(x);total13=0;for i=1:1:length(x) total13 = total13 + y13(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(7.*x).*(x>=0 & x<=1);y14=fun(x);total14=0;for i=1:1:length(x) total14 = total14 + y14(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(8.*x).*(x>=0 & x<=1);y15=fun(x);total15=0;for i=1:1:length(x) total15 = total15 + y15(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(8.*x).*(x>=0 & x<=1);y16=fun(x);total16=0;for i=1:1:length(x) total16 = total16 + y16(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(9.*x).*(x>=0 & x<=1);y17=fun(x);total17=0;for i=1:1:length(x) total17 = total17 + y17(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(9.*x).*(x>=0 & x<=1);y18=fun(x);total18=0;for i=1:1:length(x) total18 = total18 + y18(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(10.*x).*(x>=0 & x<=1);y19=fun(x);total19=0;for i=1:1:length(x) total19 = total19 + y19(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(10.*x).*(x>=0 & x<=1);y20=fun(x);total20=0;for i=1:1:length(x) total20 = total20 + y20(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(11.*x).*(x>=0 & x<=1);y21=fun(x);total21=0;for i=1:1:length(x) total21 = total21 + y21(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(11.*x).*(x>=0 & x<=1);y22=fun(x);total22=0;for i=1:1:length(x) total22 = total22 + y22(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(12.*x).*(x>=0 & x<=1);y23=fun(x);total23=0;for i=1:1:length(x) total23 = total23 + y23(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(12.*x).*(x>=0 & x<=1);y24=fun(x);total24=0;for i=1:1:length(x) total24 = total24 + y24(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(13.*x).*(x>=0 & x<=1);y25=fun(x);total25=0;for i=1:1:length(x) total25 = total25 + y25(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(13.*x).*(x>=0 & x<=1);y26=fun(x);total26=0;for i=1:1:length(x) total26 = total26 + y26(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(14.*x).*(x>=0 & x<=1);y27=fun(x);total27=0;for i=1:1:length(x) total27 = total27 + y27(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(14.*x).*(x>=0 & x<=1);y28=fun(x);total28=0;for i=1:1:length(x) total28 = total28 + y28(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(15.*x).*(x>=0 & x<=1);y29=fun(x);total29=0;for i=1:1:length(x) total29 = total29 + y29(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*sin(15.*x).*(x>=0 & x<=1);y30=fun(x);total30=0;for i=1:1:length(x) total30 = total30 + y30(i).*z(i);end%%fun=@(x) (1/sqrt(3.14)).*cos(16.*x).*(x>=0 & x<=1);y31=fun(x);total31=0;for i=1:1:length(x) total31 = total31 + y31(i).*z(i);end%%yy=total0.*y + total1.*y1 + total2.*y2 + total3.*y3 + total4.*y4+ total5.*y5 ... + total6.*y6 + total7.*y7 + total8.*y8 + total9.*y9 + total10.*y10 + total11.*y11 ... + total12.*y12 + total13.*y13 + total14.*y14 + total15.*y15 + total16.*y16 ... + total17.*y17 + total18.*y18 + total19.*y19 + total20.*y20 + total21.*y21 ... + total22.*y22 + total23.*y23 + total24.*y24 + total25.*y25 + total26.*y26 ... + total27.*y27 + total28.*y28 + total29.*y29 + total30.*y30 + total31.*y31;%yy=yy./100;yyy=[ total0 total1 total2 total3 total4 total5 ... total6 total7 total8 total9 total10 total11 ... total12 total13 total14 total15 total16 ... total17 total18 total19 total20 total21 ... total22 total23 total24 total25 total26 ... total27 total28 total29 total30 total31 ];subplot(3,5,6);plot(0:1:length(yyy)-1,yyy);xlabel('傅里叶谱');grid on;subplot(3,5,11);plot(x,yy);xlabel('傅里叶变换');grid on;%%fun=@(x) 1.*(x>-1);y=fun(x);total0=0;for i=1:1:length(x) total0 = total0 + y(i).*z(i);end%%fun=@(x)(1).*(x<=0.5) + (0).*(x>0.5);y1=fun(x);total1=0;for i=1:1:length(x) total1 = total1 + y1(i).*z(i);end%%fun1=@(x) fun(x.*2).*(x<=1/2) + fun((x-1/2).*2).*(x>1/2);y2=fun1(x);total2=0;for i=1:1:length(x) total2 = total2 + y2(i).*z(i);end%%fun2=@(x) fun(x.*2).*(x<=1/2) - fun((x-1/2).*2).*(x>1/2);y3=fun2(x);total3=0;for i=1:1:length(x) total3 = total3 + y3(i).*z(i);end%%fun11=@(x) fun1(x.*2).*(x<=1/2)+fun1((x-1/2).*2).*(x>1/2);y4=fun11(x);total4=0;for i=1:1:length(x) total4 = total4 + y4(i).*z(i);end%%fun12=@(x) fun1(x.*2).*(x<=1/2)-fun1((x-1/2).*2).*(x>1/2);y5=fun12(x);total5=0;for i=1:1:length(x) total5 = total5 + y5(i).*z(i);end%%fun21=@(x) fun2(x.*2).*(x<=1/2)+fun2((x-1/2).*2).*(x>1/2);y6=fun21(x);total6=0;for i=1:1:length(x) total6 = total6 + y6(i).*z(i);end%%fun22=@(x) fun2(x.*2).*(x<=1/2)-fun2((x-1/2).*2).*(x>1/2);y7=fun22(x);total7=0;for i=1:1:length(x) total7 = total7 + y7(i).*z(i);end%%fun111=@(x) fun11(x.*2).*(x<=1/2)+fun11((x-1/2).*2).*(x>1/2);y8=fun111(x);total8=0;for i=1:1:length(x) total8 = total8 + y8(i).*z(i);end%%fun112=@(x) fun11(x.*2).*(x<=1/2)-fun11((x-1/2).*2).*(x>1/2);y9=fun112(x);total9=0;for i=1:1:length(x) total9 = total9 + y9(i).*z(i);end%%fun121=@(x) fun12(x.*2).*(x<=1/2)+fun12((x-1/2).*2).*(x>1/2);y10=fun121(x);total10=0;for i=1:1:length(x) total10 = total10 + y10(i).*z(i);end%%fun122=@(x) fun12(x.*2).*(x<=1/2)-fun12((x-1/2).*2).*(x>1/2);y11=fun122(x);total11=0;for i=1:1:length(x) total11 = total11 + y11(i).*z(i);end%%fun211=@(x) fun21(x.*2).*(x<=1/2)+fun21((x-1/2).*2).*(x>1/2);y12=fun211(x);total12=0;for i=1:1:length(x) total12 = total12 + y12(i).*z(i);end%%fun212=@(x) fun21(x.*2).*(x<=1/2)-fun21((x-1/2).*2).*(x>1/2);y13=fun212(x);total13=0;for i=1:1:length(x) total13 = total13 + y13(i).*z(i);end%%fun221=@(x) fun22(x.*2).*(x<=1/2)+fun22((x-1/2).*2).*(x>1/2);y14=fun221(x);total14=0;for i=1:1:length(x) total14 = total14 + y14(i).*z(i);end%%fun222=@(x) fun22(x.*2).*(x<=1/2)-fun22((x-1/2).*2).*(x>1/2);y15=fun222(x);total15=0;for i=1:1:length(x) total15 = total15 + y15(i).*z(i);end%%fun1111=@(x) fun111(x.*2).*(x<=1/2)+fun111((x-1/2).*2).*(x>1/2);y16=fun1111(x);total16=0;for i=1:1:length(x) total16 = total16 + y16(i).*z(i);end%%fun1112=@(x) fun111(x.*2).*(x<=1/2)-fun111((x-1/2).*2).*(x>1/2);y17=fun1112(x);total17=0;for i=1:1:length(x) total17 = total17 + y17(i).*z(i);end%%fun1121=@(x) fun112(x.*2).*(x<=1/2)+fun112((x-1/2).*2).*(x>1/2);y18=fun1121(x);total18=0;for i=1:1:length(x) total18 = total18 + y18(i).*z(i);end%%fun1122=@(x) fun112(x.*2).*(x<=1/2)-fun112((x-1/2).*2).*(x>1/2);y19=fun1122(x);total19=0;for i=1:1:length(x) total19 = total19 + y19(i).*z(i);end%%fun1211=@(x) fun121(x.*2).*(x<=1/2)+fun121((x-1/2).*2).*(x>1/2);y20=fun1211(x);total20=0;for i=1:1:length(x) total20 = total20 + y20(i).*z(i);end%%fun1212=@(x) fun121(x.*2).*(x<=1/2)-fun121((x-1/2).*2).*(x>1/2);y21=fun1212(x);total21=0;for i=1:1:length(x) total21 = total21 + y21(i).*z(i);end%%fun1221=@(x) fun122(x.*2).*(x<=1/2)+fun122((x-1/2).*2).*(x>1/2);y22=fun1221(x);total22=0;for i=1:1:length(x) total22 = total22 + y22(i).*z(i);end%%fun1222=@(x) fun122(x.*2).*(x<=1/2)-fun122((x-1/2).*2).*(x>1/2);y23=fun1222(x);total23=0;for i=1:1:length(x) total23 = total23 + y23(i).*z(i);end%%fun2111=@(x) fun211(x.*2).*(x<=1/2)+fun211((x-1/2).*2).*(x>1/2);y24=fun2111(x);total24=0;for i=1:1:length(x) total24 = total24 + y24(i).*z(i);end%%fun2112=@(x) fun211(x.*2).*(x<=1/2)-fun211((x-1/2).*2).*(x>1/2);y25=fun2112(x);total25=0;for i=1:1:length(x) total25 = total25 + y25(i).*z(i);end%%fun2121=@(x) fun212(x.*2).*(x<=1/2)+fun212((x-1/2).*2).*(x>1/2);y26=fun2121(x);total26=0;for i=1:1:length(x) total26 = total26 + y26(i).*z(i);end%%fun2122=@(x) fun212(x.*2).*(x<=1/2)-fun212((x-1/2).*2).*(x>1/2);y27=fun2122(x);total27=0;for i=1:1:length(x) total27 = total27 + y27(i).*z(i);end%%fun2211=@(x) fun221(x.*2).*(x<=1/2)+fun221((x-1/2).*2).*(x>1/2);y28=fun2111(x);total28=0;for i=1:1:length(x) total28 = total28 + y28(i).*z(i);end%%fun2212=@(x) fun221(x.*2).*(x<=1/2)-fun221((x-1/2).*2).*(x>1/2);y29=fun2212(x);total29=0;for i=1:1:length(x) total29 = total29 + y29(i).*z(i);end%%fun2221=@(x) fun222(x.*2).*(x<=1/2)+fun222((x-1/2).*2).*(x>1/2);y30=fun2221(x);total30=0;for i=1:1:length(x) total30 = total30 + y30(i).*z(i);end%%fun2222=@(x) fun222(x.*2).*(x<=1/2)-fun222((x-1/2).*2).*(x>1/2);y31=fun2222(x);total31=0;for i=1:1:length(x) total31 = total31 + y31(i).*z(i);end%%yy=total0.*y + total1.*y1 + total2.*y2 + total3.*y3 + total4.*y4+ total5.*y5 ... + total6.*y6 + total7.*y7 + total8.*y8 + total9.*y9 + total10.*y10 + total11.*y11 ... + total12.*y12 + total13.*y13 + total14.*y14 + total15.*y15 + total16.*y16 ... + total17.*y17 + total18.*y18 + total19.*y19 + total20.*y20 + total21.*y21 ... + total22.*y22 + total23.*y23 + total24.*y24 + total25.*y25 + total26.*y26 ... + total27.*y27 + total28.*y28 + total29.*y29 + total30.*y30 + total31.*y31;%yy=yy./100;yyy=[ total0 total1 total2 total3 total4 total5 ... total6 total7 total8 total9 total10 total11 ... total12 total13 total14 total15 total16 ... total17 total18 total19 total20 total21 ... total22 total23 total24 total25 total26 ... total27 total28 total29 total30 total31 ];subplot(3,5,7);plot(0:1:length(yyy)-1,yyy);xlabel('沃什谱');grid on;subplot(3,5,12);plot(x,yy);xlabel('沃什函数');grid on;%%fun=@(x) 1.*(x>-1);y=fun(x);total0=0;for i=1:1:length(x) total0 = total0 + y(i).*z(i);end%%fun=@(x)(sqrt(3)).*(1-2.*x);y1=fun(x);total1=0;for i=1:1:length(x) total1 = total1 + y1(i).*z(i);end%%fun1=@(x) (sqrt(3).*(1-4.*x)).*(x<=1/2)+(sqrt(3).*(4.*x-3)).*(x>1/2);y2=fun1(x);total2=0;for i=1:1:length(x) total2 = total2 + y2(i).*z(i);end%%fun2=@(x) (1-6.*x).*(x<=1/2)+(5-6.*x).*(x>1/2);y3=fun2(x);total3=0;for i=1:1:length(x) total3 = total3 + y3(i).*z(i);end%%fun11=@(x) fun1(x.*2).*(x<=1/2)+fun1((x-1/2).*2).*(x>1/2);y4=fun11(x);total4=0;for i=1:1:length(x) total4 = total4 + y4(i).*z(i);end%%fun12=@(x) fun1(x.*2).*(x<=1/2)-fun1((x-1/2).*2).*(x>1/2);y5=fun12(x);total5=0;for i=1:1:length(x) total5 = total5 + y5(i).*z(i);end%%fun21=@(x) fun2(x.*2).*(x<=1/2)+fun2((x-1/2).*2).*(x>1/2);y6=fun21(x);total6=0;for i=1:1:length(x) total6 = total6 + y6(i).*z(i);end%%fun22=@(x) fun2(x.*2).*(x<=1/2)-fun2((x-1/2).*2).*(x>1/2);y7=fun22(x);total7=0;for i=1:1:length(x) total7 = total7 + y7(i).*z(i);end%%fun111=@(x) fun11(x.*2).*(x<=1/2)+fun11((x-1/2).*2).*(x>1/2);y8=fun111(x);total8=0;for i=1:1:length(x) total8 = total8 + y8(i).*z(i);end%%fun112=@(x) fun11(x.*2).*(x<=1/2)-fun11((x-1/2).*2).*(x>1/2);y9=fun112(x);total9=0;for i=1:1:length(x) total9 = total9 + y9(i).*z(i);end%%fun121=@(x) fun12(x.*2).*(x<=1/2)+fun12((x-1/2).*2).*(x>1/2);y10=fun121(x);total10=0;for i=1:1:length(x) total10 = total10 + y10(i).*z(i);end%%fun122=@(x) fun12(x.*2).*(x<=1/2)-fun12((x-1/2).*2).*(x>1/2);y11=fun122(x);total11=0;for i=1:1:length(x) total11 = total11 + y11(i).*z(i);end%%fun211=@(x) fun21(x.*2).*(x<=1/2)+fun21((x-1/2).*2).*(x>1/2);y12=fun211(x);total12=0;for i=1:1:length(x) total12 = total12 + y12(i).*z(i);end%%fun212=@(x) fun21(x.*2).*(x<=1/2)-fun21((x-1/2).*2).*(x>1/2);y13=fun212(x);total13=0;for i=1:1:length(x) total13 = total13 + y13(i).*z(i);end%%fun221=@(x) fun22(x.*2).*(x<=1/2)+fun22((x-1/2).*2).*(x>1/2);y14=fun221(x);total14=0;for i=1:1:length(x) total14 = total14 + y14(i).*z(i);end%%fun222=@(x) fun22(x.*2).*(x<=1/2)-fun22((x-1/2).*2).*(x>1/2);y15=fun222(x);total15=0;for i=1:1:length(x) total15 = total15 + y15(i).*z(i);end%%fun1111=@(x) fun111(x.*2).*(x<=1/2)+fun111((x-1/2).*2).*(x>1/2);y16=fun1111(x);total16=0;for i=1:1:length(x) total16 = total16 + y16(i).*z(i);end%%fun1112=@(x) fun111(x.*2).*(x<=1/2)-fun111((x-1/2).*2).*(x>1/2);y17=fun1112(x);total17=0;for i=1:1:length(x) total17 = total17 + y17(i).*z(i);end%%fun1121=@(x) fun112(x.*2).*(x<=1/2)+fun112((x-1/2).*2).*(x>1/2);y18=fun1121(x);total18=0;for i=1:1:length(x) total18 = total18 + y18(i).*z(i);end%%fun1122=@(x) fun112(x.*2).*(x<=1/2)-fun112((x-1/2).*2).*(x>1/2);y19=fun1122(x);total19=0;for i=1:1:length(x) total19 = total19 + y19(i).*z(i);end%%fun1211=@(x) fun121(x.*2).*(x<=1/2)+fun121((x-1/2).*2).*(x>1/2);y20=fun1211(x);total20=0;for i=1:1:length(x) total20 = total20 + y20(i).*z(i);end%%fun1212=@(x) fun121(x.*2).*(x<=1/2)-fun121((x-1/2).*2).*(x>1/2);y21=fun1212(x);total21=0;for i=1:1:length(x) total21 = total21 + y21(i).*z(i);end%%fun1221=@(x) fun122(x.*2).*(x<=1/2)+fun122((x-1/2).*2).*(x>1/2);y22=fun1221(x);total22=0;for i=1:1:length(x) total22 = total22 + y22(i).*z(i);end%%fun1222=@(x) fun122(x.*2).*(x<=1/2)-fun122((x-1/2).*2).*(x>1/2);y23=fun1222(x);total23=0;for i=1:1:length(x) total23 = total23 + y23(i).*z(i);end%%fun2111=@(x) fun211(x.*2).*(x<=1/2)+fun211((x-1/2).*2).*(x>1/2);y24=fun2111(x);total24=0;for i=1:1:length(x) total24 = total24 + y24(i).*z(i);end%%fun2112=@(x) fun211(x.*2).*(x<=1/2)-fun211((x-1/2).*2).*(x>1/2);y25=fun2112(x);total25=0;for i=1:1:length(x) total25 = total25 + y25(i).*z(i);end%%fun2121=@(x) fun212(x.*2).*(x<=1/2)+fun212((x-1/2).*2).*(x>1/2);y26=fun2121(x);total26=0;for i=1:1:length(x) total26 = total26 + y26(i).*z(i);end%%fun2122=@(x) fun212(x.*2).*(x<=1/2)-fun212((x-1/2).*2).*(x>1/2);y27=fun2122(x);total27=0;for i=1:1:length(x) total27 = total27 + y27(i).*z(i);end%%fun2211=@(x) fun221(x.*2).*(x<=1/2)+fun221((x-1/2).*2).*(x>1/2);y28=fun2111(x);total28=0;for i=1:1:length(x) total28 = total28 + y28(i).*z(i);end%%fun2212=@(x) fun221(x.*2).*(x<=1/2)-fun221((x-1/2).*2).*(x>1/2);y29=fun2212(x);total29=0;for i=1:1:length(x) total29 = total29 + y29(i).*z(i);end%%fun2221=@(x) fun222(x.*2).*(x<=1/2)+fun222((x-1/2).*2).*(x>1/2);y30=fun2221(x);total30=0;for i=1:1:length(x) total30 = total30 + y30(i).*z(i);end%%fun2222=@(x) fun222(x.*2).*(x<=1/2)-fun222((x-1/2).*2).*(x>1/2);y31=fun2222(x);total31=0;for i=1:1:length(x) total31 = total31 + y31(i).*z(i);end%%yy=total0.*y + total1.*y1 + total2.*y2 + total3.*y3 + total4.*y4+ total5.*y5 ... + total6.*y6 + total7.*y7 + total8.*y8 + total9.*y9 + total10.*y10 + total11.*y11 ... + total12.*y12 + total13.*y13 + total14.*y14 + total15.*y15 + total16.*y16 ... + total17.*y17 + total18.*y18 + total19.*y19 + total20.*y20 + total21.*y21 ... + total22.*y22 + total23.*y23 + total24.*y24 + total25.*y25 + total26.*y26 ... + total27.*y27 + total28.*y28 + total29.*y29 + total30.*y30 + total31.*y31;%yy=yy./100;yyy=[ total0 total1 total2 total3 total4 total5 ... total6 total7 total8 total9 total10 total11 ... total12 total13 total14 total15 total16 ... total17 total18 total19 total20 total21 ... total22 total23 total24 total25 total26 ... total27 total28 total29 total30 total31 ];subplot(3,5,8);plot(0:1:length(yyy)-1,yyy);xlabel('K=1 U系统谱');grid on;subplot(3,5,13);plot(x,yy);xlabel('K=1 U系统');grid on;%%fun0=@(x) 1.*(x>-1);y=fun0(x);total0=0;for i=1:1:length(x) total0 = total0 + y(i).*z(i);end%%fun=@(x)(1).*(x<=0.5) + (0).*(x>0.5);y1=fun(x);total1=0;for i=1:1:length(x) total1 = total1 + y1(i).*z(i);end%%fun11=@(x) fun(x.*2-0).*(x>=0&x<=0+1/2);y2=fun11(x);total2=0;for i=1:1:length(x) total2 = total2 + y2(i).*z(i);end%%fun12=@(x) fun(x.*2-1).*(x>=1/2&x<=1/2+1/2);y3=fun12(x);total3=0;for i=1:1:length(x) total3 = total3 + y3(i).*z(i);end%%fun21=@(x) fun(x.*4-0).*(x>=0&x<=0+1/4);y4=fun21(x);total4=0;for i=1:1:length(x) total4 = total4 + y4(i).*z(i);end%%fun22=@(x) fun(x.*4-1).*(x>=1/4&x<=1/4+1/4);y5=fun22(x);total5=0;for i=1:1:length(x) total5 = total5 + y5(i).*z(i);end%%fun23=@(x) fun(x.*4-2).*(x>=2/4&x<=2/4+1/4);y6=fun23(x);total6=0;for i=1:1:length(x) total6 = total6 + y6(i).*z(i);end%%fun24=@(x) fun(x.*4-3).*(x>=3/4&x<=3/4+1/4);y7=fun24(x);total7=0;for i=1:1:length(x) total7 = total7 + y7(i).*z(i);end%%fun31=@(x) fun(x.*8-0).*(x>=0&x<=0+1/8);y8=fun31(x);total8=0;for i=1:1:length(x) total8 = total8 + y8(i).*z(i);end%%fun32=@(x) fun(x.*8-1).*(x>=1/8&x<=1/8+1/8);y9=fun32(x);total9=0;for i=1:1:length(x) total9 = total9 + y9(i).*z(i);end%%fun33=@(x) fun(x.*8-2).*(x>=2/8&x<=2/8+1/8);y10=fun33(x);total10=0;for i=1:1:length(x) total10 = total10 + y10(i).*z(i);end%%fun34=@(x) fun(x.*8-3).*(x>=3/8&x<=3/8+1/8);y11=fun34(x);total11=0;for i=1:1:length(x) total11 = total11 + y11(i).*z(i);end%%fun35=@(x) fun(x.*8-4).*(x>=4/8&x<=4/8+1/8);y12=fun35(x);total12=0;for i=1:1:length(x) total12 = total12 + y12(i).*z(i);end%%fun36=@(x) fun(x.*8-5).*(x>=5/8&x<=5/8+1/8);y13=fun36(x);total13=0;for i=1:1:length(x) total13 = total13 + y13(i).*z(i);end%%fun37=@(x) fun(x.*8-6).*(x>=6/8&x<=6/8+1/8);y14=fun37(x);total14=0;for i=1:1:length(x) total14 = total14 + y14(i).*z(i);end%%fun38=@(x) fun(x.*8-7).*(x>=7/8&x<=7/8+1/8);y15=fun38(x);total15=0;for i=1:1:length(x) total15 = total15 + y15(i).*z(i);end%%fun41=@(x) fun(x.*16-0).*(x>=0&x<=0+1/16);y16=fun41(x);total16=0;for i=1:1:length(x) total16 = total16 + y16(i).*z(i);end%%fun42=@(x) fun(x.*16-1).*(x>=1/16&x<=1/16+1/16);y17=fun42(x);total17=0;for i=1:1:length(x) total17 = total17 + y17(i).*z(i);end%%fun43=@(x) fun(x.*16-2).*(x>=2/16&x<=2/16+1/16);y18=fun43(x);total18=0;for i=1:1:length(x) total18 = total18 + y18(i).*z(i);end%%fun44=@(x) fun(x.*16-3).*(x>=3/16&x<=3/16+1/16);y19=fun44(x);total19=0;for i=1:1:length(x) total19 = total19 + y19(i).*z(i);end%%fun45=@(x) fun(x.*16-4).*(x>=4/16&x<=4/16+1/16);y20=fun45(x);total20=0;for i=1:1:length(x) total20 = total20 + y20(i).*z(i);end%%fun46=@(x) fun(x.*16-5).*(x>=5/16&x<=5/16+1/16);y21=fun46(x);total21=0;for i=1:1:length(x) total21 = total21 + y21(i).*z(i);end%%fun47=@(x) fun(x.*16-6).*(x>=6/16&x<=6/16+1/16);y22=fun47(x);total22=0;for i=1:1:length(x) total22 = total22 + y22(i).*z(i);end%%fun48=@(x) fun(x.*16-7).*(x>=7/16&x<=7/16+1/16);y23=fun48(x);total23=0;for i=1:1:length(x) total23 = total23 + y23(i).*z(i);end%%fun49=@(x) fun(x.*16-8).*(x>=8/16&x<=8/16+1/16);y24=fun49(x);total24=0;for i=1:1:length(x) total24 = total24 + y24(i).*z(i);end%%fun410=@(x) fun(x.*16-9).*(x>=9/16&x<=9/16+1/16);y25=fun410(x);total25=0;for i=1:1:length(x) total25 = total25 + y25(i).*z(i);end%%fun411=@(x) fun(x.*16-10).*(x>=10/16&x<=10/16+1/16);y26=fun411(x);total26=0;for i=1:1:length(x) total26 = total26 + y26(i).*z(i);end%%fun412=@(x) fun(x.*16-11).*(x>=11/16&x<=11/16+1/16);y27=fun412(x);total27=0;for i=1:1:length(x) total27 = total27 + y27(i).*z(i);end%%fun413=@(x) fun(x.*16-12).*(x>=12/16&x<=12/16+1/16);y28=fun413(x);total28=0;for i=1:1:length(x) total28 = total28 + y28(i).*z(i);end%%fun414=@(x) fun(x.*16-13).*(x>=13/16&x<=13/16+1/16);y29=fun414(x);total29=0;for i=1:1:length(x) total29 = total29 + y29(i).*z(i);end%%fun415=@(x) fun(x.*16-14).*(x>=14/16&x<=14/16+1/16);y30=fun415(x);total30=0;for i=1:1:length(x) total30 = total30 + y30(i).*z(i);end%%fun416=@(x) fun(x.*16-15).*(x>=15/16&x<=15/16+1/16);y31=fun416(x);total31=0;for i=1:1:length(x) total31 = total31 + y31(i).*z(i);end%%yy=total0.*y + total1.*y1 + total2.*y2 + total3.*y3 + total4.*y4+ total5.*y5 ... + total6.*y6 + total7.*y7 + total8.*y8 + total9.*y9 + total10.*y10 + total11.*y11 ... + total12.*y12 + total13.*y13 + total14.*y14 + total15.*y15 + total16.*y16 ... + total17.*y17 + total18.*y18 + total19.*y19 + total20.*y20 + total21.*y21 ... + total22.*y22 + total23.*y23 + total24.*y24 + total25.*y25 + total26.*y26 ... + total27.*y27 + total28.*y28 + total29.*y29 + total30.*y30 + total31.*y31;%yy=yy./100;yyy=[ total0 total1 total2 total3 total4 total5 ... total6 total7 total8 total9 total10 total11 ... total12 total13 total14 total15 total16 ... total17 total18 total19 total20 total21 ... total22 total23 total24 total25 total26 ... total27 total28 total29 total30 total31 ];subplot(3,5,9);plot(0:1:length(yyy)-1,yyy);xlabel('哈尔谱');grid on;subplot(3,5,14);plot(x,yy);xlabel('哈尔函数');grid on;%%fun0=@(x) 1.*(x>-1);y=fun0(x);total0=0;for i=1:1:length(x) total0 = total0 + y(i).*z(i);end%%fun=@(x)(sqrt(3)).*(1-2.*x);y1=fun(x);total1=0;for i=1:1:length(x) total1 = total1 + y1(i).*z(i);end%%fun1=@(x) (sqrt(3).*(1-4.*x)).*(x<=1/2)+(sqrt(3).*(4.*x-3)).*(x>1/2);y2=fun1(x);total2=0;for i=1:1:length(x) total2 = total2 + y2(i).*z(i);end%%fun2=@(x) (1-6.*x).*(x<=1/2)+(5-6.*x).*(x>1/2);y3=fun2(x);total3=0;for i=1:1:length(x) total3 = total3 + y3(i).*z(i);end%%fun11=@(x) fun1(x.*2-0).*(x>=0&x<=0+1/2);y4=fun11(x);total4=0;for i=1:1:length(x) total4 = total4 + y4(i).*z(i);end%%fun12=@(x) fun1(x.*2-1).*(x>=1/2&x<=1/2+1/2);y5=fun12(x);total5=0;for i=1:1:length(x) total5 = total5 + y5(i).*z(i);end%%fun21=@(x) fun2(x.*2-0).*(x>=0&x<=0+1/2);y6=fun21(x);total6=0;for i=1:1:length(x) total6 = total6 + y6(i).*z(i);end%%fun22=@(x) fun2(x.*2-1).*(x>=1/2&x<=1/2+1/2);y7=fun22(x);total7=0;for i=1:1:length(x) total7 = total7 + y7(i).*z(i);end%%fun111=@(x) fun11(x.*4-0).*(x>=0&x<=0+1/4);y8=fun111(x);total8=0;for i=1:1:length(x) total8 = total8 + y8(i).*z(i);end%%fun112=@(x) fun11(x.*4-1).*(x>=1/4&x<=1/4+1/4);y9=fun112(x);total9=0;for i=1:1:length(x) total9 = total9 + y9(i).*z(i);end%%fun113=@(x) fun11(x.*4-2).*(x>=2/4&x<=2/4+1/4);y10=fun113(x);total10=0;for i=1:1:length(x) total10 = total10 + y10(i).*z(i);end%%fun114=@(x) fun11(x.*4-3).*(x>=3/4&x<=3/4+1/4);y11=fun114(x);total11=0;for i=1:1:length(x) total11 = total11 + y11(i).*z(i);end%%fun121=@(x) fun12(x.*4-0).*(x>=0&x<=0+1/4);y12=fun121(x);total12=0;for i=1:1:length(x) total12 = total12 + y12(i).*z(i);end%%fun122=@(x) fun12(x.*4-1).*(x>=1/4&x<=1/4+1/4);y13=fun122(x);total13=0;for i=1:1:length(x) total13 = total13 + y13(i).*z(i);end%%fun123=@(x) fun12(x.*4-2).*(x>=2/4&x<=2/4+1/4);y14=fun123(x);total14=0;for i=1:1:length(x) total14 = total14 + y14(i).*z(i);end%%fun124=@(x) fun12(x.*4-3).*(x>=3/4&x<=3/4+1/4);y15=fun124(x);total15=0;for i=1:1:length(x) total15 = total15 + y15(i).*z(i);end%%fun211=@(x) fun21(x.*4-0).*(x>=0&x<=0+1/4);y16=fun211(x);total16=0;for i=1:1:length(x) total16 = total16 + y16(i).*z(i);end%%fun212=@(x) fun21(x.*4-1).*(x>=1/4&x<=1/4+1/4);y17=fun212(x);total17=0;for i=1:1:length(x) total17 = total17 + y17(i).*z(i);end%%fun213=@(x) fun21(x.*4-2).*(x>=2/4&x<=2/4+1/4);y18=fun213(x);total18=0;for i=1:1:length(x) total18 = total18 + y18(i).*z(i);end%%fun214=@(x) fun21(x.*4-3).*(x>=3/4&x<=3/4+1/4);y19=fun214(x);total19=0;for i=1:1:length(x) total19 = total19 + y19(i).*z(i);end%%fun221=@(x) fun22(x.*4-0).*(x>=0&x<=0+1/4);y20=fun221(x);total20=0;for i=1:1:length(x) total20 = total20 + y20(i).*z(i);end%%fun222=@(x) fun22(x.*4-1).*(x>=1/4&x<=1/4+1/4);y21=fun222(x);total21=0;for i=1:1:length(x) total21 = total21 + y21(i).*z(i);end%%fun223=@(x) fun22(x.*4-2).*(x>=2/4&x<=2/4+1/4);y22=fun223(x);total22=0;for i=1:1:length(x) total22 = total22 + y22(i).*z(i);end%%fun224=@(x) fun22(x.*4-3).*(x>=3/4&x<=3/4+1/4);y23=fun224(x);total23=0;for i=1:1:length(x) total23 = total23 + y23(i).*z(i);end%%fun1111=@(x) fun111(x.*8-0).*(x>=0&x<=0+1/8);y24=fun1111(x);total24=0;for i=1:1:length(x) total24 = total24 + y24(i).*z(i);end%%fun1112=@(x) fun111(x.*8-1).*(x>=1/8&x<=1/8+1/8);y25=fun1112(x);total25=0;for i=1:1:length(x) total25 = total25 + y25(i).*z(i);end%%fun1113=@(x) fun111(x.*8-2).*(x>=2/8&x<=2/8+1/8);y26=fun1113(x);total26=0;for i=1:1:length(x) total26 = total26 + y26(i).*z(i);end%%fun1114=@(x) fun111(x.*8-3).*(x>=3/8&x<=3/8+1/8);y27=fun1114(x);total27=0;for i=1:1:length(x) total27 = total27 + y27(i).*z(i);end%%fun1115=@(x) fun111(x.*8-4).*(x>=4/8&x<=4/8+1/8);y28=fun1115(x);total28=0;for i=1:1:length(x) total28 = total28 + y28(i).*z(i);end%%fun1116=@(x) fun111(x.*8-5).*(x>=5/8&x<=5/8+1/8);y29=fun1116(x);total29=0;for i=1:1:length(x) total29 = total29 + y29(i).*z(i);end%%fun1117=@(x) fun111(x.*8-6).*(x>=6/8&x<=6/8+1/8);y30=fun1117(x);total30=0;for i=1:1:length(x) total30 = total30 + y30(i).*z(i);end%%fun1118=@(x) fun111(x.*8-7).*(x>=7/8&x<=7/8+1/8);y31=fun1118(x);total31=0;for i=1:1:length(x) total31 = total31 + y31(i).*z(i);end%%yy=total0.*y + total1.*y1 + total2.*y2 + total3.*y3 + total4.*y4+ total5.*y5 ... + total6.*y6 + total7.*y7 + total8.*y8 + total9.*y9 + total10.*y10 + total11.*y11 ... + total12.*y12 + total13.*y13 + total14.*y14 + total15.*y15 + total16.*y16 ... + total17.*y17 + total18.*y18 + total19.*y19 + total20.*y20 + total21.*y21 ... + total22.*y22 + total23.*y23 + total24.*y24 + total25.*y25 + total26.*y26 ... + total27.*y27 + total28.*y28 + total29.*y29 + total30.*y30 + total31.*y31;%yy=yy./100;yyy=[ total0 total1 total2 total3 total4 total5 ... total6 total7 total8 total9 total10 total11 ... total12 total13 total14 total15 total16 ... total17 total18 total19 total20 total21 ... total22 total23 total24 total25 total26 ... total27 total28 total29 total30 total31 ];subplot(3,5,10);plot(0:1:length(yyy)-1,yyy);xlabel('K=1 V系统谱');grid on;subplot(3,5,15);plot(x,yy);xlabel('K=1 V系统');grid on;