24小时热门版块排行榜    

查看: 1653  |  回复: 1

☆皓月当空☆

新虫 (初入文坛)

[交流] 用MATLAB或者C语言生成一维随机粗糙面

现在急需要粗糙面程序用你模拟电磁散射,MATLAB或者C语言都可以,希望大虫们帮个忙,感激不尽,呵呵!
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

osd1888

铁杆木虫 (正式写手)


小木虫: 金币+0.5, 给个红包,谢谢回帖
function [f,df,x]=rsgeng(N,rL,h,lc,seed);
%   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=1N/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));
2楼2015-02-04 21:13:16
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 ☆皓月当空☆ 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见