|
今天,回答别人的问题。是生成海浪的。看着,可是真亲切啊。
想想那时,为了一个程序,能折腾半个月。机器,也不行。水平也不行。
- clear all
- clc
- pinpushu=20;
- fengji=7;
- jiaodushu=360;
- wavewmin = [2.438306 1.462983 1.044989 0.812770 0.664988 0.562683 0.487659 0.430288];
- wavewmax = [16.444115 9.866469 7.047480 5.481373 4.484760 3.794799 3.288826 2.90190];
- wavewp=[4.053570 2.432142 1.737244 1.351190 1.105519 0.935439 0.810714 0.715336];
- %-----------------------------------------------------
- u=[3,5,7,9,11,13,15,17];
- %---------------------------------------------------
- if fengji>8
- fengji=8;
- end
- if fengji<1
- fengji=1;
- end
- fi=fengji;
- wmin=wavewmin(fi);
- wmax=wavewmax(fi);
- wp=wavewp(fi);
- ui=u(fi);
- M=pinpushu;
- N=jiaodushu;
- wavewn=(wmax-wmin)/M;
- thetawn=pi/N;
- dx=1;
- dy=1;
- x=[0:dx:100];
- y=[0:dy:80];
- [x,y]=meshgrid(x,y);
- z=zeros(size(x));
- for wi=1:M
- for ki=1:N
- theta=-pi/2+(ki-1)*thetawn;
- epsin=rand*2*pi;
- w=wmin+(wi-1)*wavewn+wavewn/2;
- swi=0.81*exp(-7400/(w*ui+epsin).^4)*2*(cos(theta)).^2/(pi*(w.^5+epsin));
- % swi=0.81*exp(-7400/(w*ui).^4)*2*(cos(theta)).^2/(pi*(w.^5));
-
- if swi > 100*eps
- % M
- % N
- an=sqrt(abs(2*swi*wavewn*theta));
- % an=1;
- z1=w*w*x*cos(theta)/9.8+w*w*y*sin(theta)/9.8+epsin;
- z=an*cos(z1)+z;
- end
- end
- end
- surf(x,y,z);
- shading interp;%shading interp 会区分每个线形区域的颜色,并且插入与其相近的颜色
- lightangle(-45,30);
- set(findobj(gca,'type','surface'),'FaceLighting','phong','AmbientStrength',.3,'DiffuseStrength',.8,...
- 'SpecularStrength',.9,'SpecularExponent',200)
- h=gcf;
- fig_na=['./fig_wave'];
- % fun_work_li_035_myfig_out(h,fig_na,3);
复制代码
|
|