| 6 | 1/1 | 返回列表 |
| 查看: 3477 | 回復(fù): 5 | ||
23點(diǎn)雨新蟲 (小有名氣)
|
[求助]
求MATLAB生成二維高斯粗糙面的代碼 已有1人參與
|
| 各位大神 誰能提供生成二維高斯粗糙面的代碼,謝謝了! |

鐵桿木蟲 (正式寫手)
|
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' ) |
新蟲 (小有名氣)

新蟲 (小有名氣)

| 6 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研]
|
.6lL 2026-03-18 | 5/250 |
|
|---|---|---|---|---|
|
[考研] 一志愿吉林大學(xué)材料學(xué)碩321求調(diào)劑 +4 | Ymlll 2026-03-18 | 6/300 |
|
|
[考研] 0703化學(xué) 305求調(diào)劑 +3 | FY_yy 2026-03-14 | 3/150 |
|
|
[考研] 化學(xué)工程321分求調(diào)劑 +15 | 大米飯! 2026-03-15 | 18/900 |
|
|
[考研] 303求調(diào)劑 +4 | 睿08 2026-03-17 | 6/300 |
|
|
[考研] 材料,紡織,生物(0856、0710),化學(xué)招生啦 +3 | Eember. 2026-03-17 | 9/450 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機(jī)?/a> 2026-03-16 | 3/150 |
|
|
[考研] 296求調(diào)劑 +5 | 大口吃飯 身體健 2026-03-13 | 5/250 |
|
|
[考研] 085601求調(diào)劑 +4 | Du.11 2026-03-16 | 4/200 |
|
|
[考研] 一志愿,福州大學(xué)材料專碩339分求調(diào)劑 +3 | 木子momo青爭 2026-03-15 | 3/150 |
|
|
[考研] 中科院材料273求調(diào)劑 +4 | yzydy 2026-03-15 | 4/200 |
|
|
[考研] 0703化學(xué)調(diào)劑 290分有科研經(jīng)歷,論文在投 +7 | 膩膩gk 2026-03-14 | 7/350 |
|
|
[考研] 326求調(diào)劑 +3 | mlpqaz03 2026-03-15 | 3/150 |
|
|
[考研] 294求調(diào)劑 +3 | Zys010410@ 2026-03-13 | 4/200 |
|
|
[基金申請] 現(xiàn)在如何回避去年的某一個專家,不知道名字 +3 | zk200107 2026-03-12 | 6/300 |
|
|
[考研] 297求調(diào)劑 +4 | 學(xué)海漂泊 2026-03-13 | 4/200 |
|
|
[考研] 學(xué)碩285求調(diào)劑 +13 | Wisjxn 2026-03-12 | 46/2300 |
|
|
[考研] [0860]321分求調(diào)劑,ab區(qū)皆可 +4 | 寶貴熱 2026-03-13 | 4/200 |
|
|
[考研] 考研調(diào)劑 +4 | 芬達(dá)46 2026-03-12 | 4/200 |
|
|
[考研] 081200-11408-276學(xué)碩求調(diào)劑 +3 | 崔wj 2026-03-12 | 4/200 |
|