| 6 | 1/1 | 返回列表 |
| 查看: 3478 | 回復: 5 | ||
23點雨新蟲 (小有名氣)
|
[求助]
求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ā)表 | |
|---|---|---|---|---|
|
[考研] 267一志愿南京工業(yè)大學0817化工求調(diào)劑 +8 | SUICHILD 2026-03-12 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 295求調(diào)劑 +3 | 一志愿京區(qū)211 2026-03-18 | 5/250 |
|
|
[考研] 化學工程321分求調(diào)劑 +15 | 大米飯! 2026-03-15 | 18/900 |
|
|
[考研] 297求調(diào)劑 +8 | 戲精丹丹丹 2026-03-17 | 8/400 |
|
|
[考研] 312求調(diào)劑 +8 | 陌宸希 2026-03-16 | 9/450 |
|
|
[考研] 0703化學求調(diào)劑 總分331 +3 | ZY-05 2026-03-13 | 3/150 |
|
|
[考研] 有沒有道鐵/土木的想調(diào)劑南林,給自己招師弟中~ +3 | TqlXswl 2026-03-16 | 7/350 |
|
|
[考研] 材料與化工專碩調(diào)劑 +5 | heming3743 2026-03-16 | 5/250 |
|
|
[考研] 278求調(diào)劑 +3 | Yy7400 2026-03-13 | 3/150 |
|
|
[考研] 東南大學364求調(diào)劑 +5 | JasonYuiui 2026-03-15 | 5/250 |
|
|
[考研] 085600調(diào)劑 +5 | 漾漾123sun 2026-03-12 | 6/300 |
|
|
[考研] 277材料科學與工程080500求調(diào)劑 +3 | 自由煎餅果子 2026-03-16 | 3/150 |
|
|
[考研] 22408總分284求調(diào)劑 +3 | InAspic 2026-03-13 | 3/150 |
|
|
[考研] 材料與化工(0856)304求B區(qū)調(diào)劑 +6 | 邱gl 2026-03-12 | 7/350 |
|
|
[考研] 求材料調(diào)劑 085600英一數(shù)二總分302 前三科235 精通機器學習 一志愿哈工大 +4 | 林yaxin 2026-03-12 | 4/200 |
|
|
[考研] 26調(diào)劑/材料科學與工程/總分295/求收留 +9 | 2026調(diào)劑俠 2026-03-12 | 9/450 |
|
|
[考研] 274求調(diào)劑 +3 | S.H1 2026-03-12 | 3/150 |
|
|
[考研] 328化工專碩求調(diào)劑 +4 | 。,。,。,。i 2026-03-12 | 4/200 |
|
|
[考研] 一志愿山大07化學 332分 四六級已過 本科山東雙非 求調(diào)劑! +3 | 不想理你 2026-03-12 | 3/150 |
|
|
[考博] 福州大學楊黃浩課題組招收2026年專業(yè)學位博士研究生,2026.03.20截止 +3 | Xiangyu_ou 2026-03-12 | 3/150 |
|