| 5 | 1/1 | 返回列表 |
| 查看: 3491 | 回復(fù): 5 | ||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | ||
23點(diǎn)雨新蟲 (小有名氣)
|
[求助]
求MATLAB生成二維高斯粗糙面的代碼 已有1人參與
|
|
| 各位大神 誰(shuí)能提供生成二維高斯粗糙面的代碼,謝謝了! |

新蟲 (小有名氣)

鐵桿木蟲 (正式寫手)
|
function [f,df,x]=rsgeng(N,rL,h,lc,seed); % RSGENG generates 1D Gaussian random rough surfaces with Gaussian Spectrum. % INPUT: % N=total number of sample points % rL=rough surface length % h=rms height % lc=correlation length % seed=seed of random number generator % % OUTPUT: % f=rough surface profile % df=df/dx % x=sample points on the surface % randn('seed',seed); y=randn(N,1); for n=1 N/2-1);bh(n)=(y(2*n-1)+i*y(2*n))/sqrt(2); end; bhc=conj(bh); bhf=fliplr(bhc); bi=[bh y(N-1) bhf y(N)]; kx=2*pi*[-N/2+1:1:N/2]/rL; y1=sqrt(wk(kx,h,lc)); y=y1*sqrt(2*pi*rL); b=y.*bi; xs=[b(N/2+1:1:N) b(1:1:N/2)]; xt=[xs(N),xs(1:1:N-1)]; ft=ifft(xt,N); ft=ft*N/rL; fs=[ft(2:1:N),ft(1)]; f=[fs(N/2+1:1:N) fs(1:1:N/2)]; f=real(f); dx=rL/N; x=[-N/2+1:1:N/2]*dx; n=2:N-1; df1=(f(n+1)-f(n-1))/(2*dx); df=[(f(2)-f(N))/(2*dx),df1,(f(1)-f(N-1))/(2*dx)]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Gaussian spectral density % %%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=wk(kx,h,lc) y=h^2*lc*exp(-(kx*lc*0.5).^2)/(2*sqrt(pi)); |
鐵桿木蟲 (正式寫手)
|
%********** INPUTS *********************************** %SELECT GRID SIZE: N=NUMBER OF GRID NODES N=128; %For efficiency (FFTs) N should be a power of 2 %SELECT GRID SPACING, CORRELATION LENGTH, %AND SURFACE HEIGHT VARIANCE, ALL IN METERS %(NOTE: delx should be smaller than lc for ) %( good surface representation) lambda=10./3.; %radiation wavelength (m) lc =1.000*lambda; %transverse correlation length (m) zdev=0.100*lambda; %surface height variance (m) delx=lambda/7.; %cell size (grid spacing) (m) %********** END INPUTS ******************************** %CREATE 2-D GAUSSIAN FILTER %normalize correlation length to cel1 size lc=lc/delx; %x and y are dimensionless for now x=linspace(-(N-1)/2,(N-1)/2,N);y=x; %x and y coords. for each grid pt. [X,Y]=meshgrid(x,y); %2-D filter G=exp((-X.^2 -Y.^2)/(lc.^2/2.))/(sqrt(pi)*lc/2.); %scale x and y axes to be meters for future use x=x*delx;y=y*delx; %CREATE GAUSSIAN DISTRIBUTED, UNCORRELATED RANDOM SURFACE R=randn(size(G)) ; %USE 2-D CIRCULAR CONVOLUTION TO MAKE GAUSSIAN CORRELATED SURFACE %WITH CORRELATION LENGTH lc (celIs) aud STANDARD DEVIATION 1. Z=ifft2(fft2(R).*fft2(G));%Circular convolution of R ald G via FFT Z=real(Z); %Convolution of two real arrays is real Z=Z*zdev; %scale to obtain desired std.dev.(m) %PLOT THE SURFACE figure mesh(x,y,Z) %random surface axis ([min(x),max(x),min(y),max(y),min(min(Z))*2,max(max(Z))*2]); xlabel('x (m)'); ylabel('y (m)'); zlabel('z (m)'); title ('Random Surface' ) |
新蟲 (小有名氣)

| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑,一志愿:南京航空航天大學(xué)大學(xué) ,080500材料科學(xué)與工程學(xué)碩,總分289分 +5 | @taotao 2026-03-19 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 0854電子信息求調(diào)劑 +6 | α____ 2026-03-22 | 7/350 |
|
|
[考研] 306求0703調(diào)劑一志愿華中師范 +10 | 紙魚ly 2026-03-21 | 11/550 |
|
|
[考研] 384求調(diào)劑 +3 | 子系博 2026-03-22 | 6/300 |
|
|
[考研] 316求調(diào)劑 +7 | 梁茜雯 2026-03-19 | 7/350 |
|
|
[考研] 一志愿華中農(nóng)業(yè)071010,總分320求調(diào)劑 +5 | 困困困困坤坤 2026-03-20 | 6/300 |
|
|
[考研] 287求調(diào)劑 +8 | 晨昏線與星海 2026-03-19 | 9/450 |
|
|
[考研] 275求調(diào)劑 +6 | shansx 2026-03-22 | 8/400 |
|
|
[考研] 311求調(diào)劑 +3 | 26研0 2026-03-20 | 3/150 |
|
|
[考研] 材料學(xué)碩333求調(diào)劑 +3 | 北道巷 2026-03-18 | 3/150 |
|
|
[考研] 311求調(diào)劑 +3 | 勇敢的小吳 2026-03-20 | 3/150 |
|
|
[考研] 299求調(diào)劑 +5 | shxchem 2026-03-20 | 7/350 |
|
|
[考研] 330求調(diào)劑0854 +3 | assdll 2026-03-21 | 3/150 |
|
|
[考研] 一志愿武理材料305分求調(diào)劑 +6 | 想上岸的鯉魚 2026-03-18 | 7/350 |
|
|
[考研] 一志愿重慶大學(xué)085700資源與環(huán)境專碩,總分308求調(diào)劑 +3 | 墨墨漠 2026-03-18 | 3/150 |
|
|
[考研] 317求調(diào)劑 +5 | 申子申申 2026-03-19 | 9/450 |
|
|
[考研] 中南大學(xué)化學(xué)學(xué)碩337求調(diào)劑 +3 | niko- 2026-03-19 | 6/300 |
|
|
[考研] 353求調(diào)劑 +3 | 拉鉤不許變 2026-03-20 | 3/150 |
|
|
[考研] 086500 325 求調(diào)劑 +3 | 領(lǐng)帶小熊 2026-03-19 | 3/150 |
|
|
[考研] 材料學(xué)碩318求調(diào)劑 +5 | February_Feb 2026-03-19 | 5/250 |
|