필터 지우기
필터 지우기

I created an 3D sinusoidal surface. And want to add a normally distributed random noise of zero mean and 0.03mm standard deviation. But it said error on the line with*. Subscripted assignment dimension mismatch. could someone help me check it please

조회 수: 4 (최근 30일)
%3D sinusoidal surface dx=0.001; %spacing in x in mm dy=0.001; %number of points along x and y nx=128; ny=128; %n=8000; %generate array of x & y x=(0:1:nx-1)*dx; y=(0:1:ny-1)*dy; for j=1:ny for i=1:nx z(j,i)=2*sin(2*pi*x(i)/0.064)+normrnd(0,0.03*ones(nx,1)); end end z=z-mean(mean(z));%shift to 0 mean mesh(x,y,z)

답변 (2개)

Youssef  Khmou
Youssef Khmou 2013년 8월 19일
편집: Youssef Khmou 2013년 8월 19일
Jianxiang,
As you use x,y loops , at each iteration the CPU computes only one scalar while you used the function normrnd of size 128*1, you can adjust your method :
%3D sinusoidal surface
dx=0.001; %spacing in x in mm
dy=0.001; %number of
%points along x and y
nx=128; ny=128; %
n=8000; %generate array of x & y
x=(0:1:nx-1)*dx;
y=(0:1:ny-1)*dy;
for j=1:ny
for i=1:nx
z(j,i)=2*sin(2*pi*x(i)/0.064)+normrnd(0,0.03);
end
end
z=z-mean(mean(z));%shift to 0 mean mesh(x,y,z)
Or you can simply add the Gaussian noise like the following :
Z=z+normrnd(0,0.03,nx,ny);

muna majeed
muna majeed 2015년 8월 4일
please can help me to add noise to 3d mesh triangle

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by