MATLAB Answers

3D surface (sine wave)

265 views (last 30 days)
Hello, How can I create 3D surface (sine wave)and plote it? Thank you very much

  0 Comments

Sign in to comment.

Accepted Answer

Kye Taylor
Kye Taylor on 28 Mar 2012
One possibility is to use the following:
k1 = 1; %how many times you want wave to oscillate in x-dir
k2 = 0; %how many times you want wave to oscillate in y-dir
[X,Y] = meshgrid(linspace(-pi,pi));
Z = cos(k1*X).*cos(k2*Y);
Change k1 and k2 for fun.

  0 Comments

Sign in to comment.

More Answers (2)

Gnaneswar Nadh satapathi
Gnaneswar Nadh satapathi on 1 Feb 2015
x=-15:0.5:15; y=-15:0.5:15; [X,Y] = meshgrid(x,y); % greate rectangullar mesh R=sqrt(X.^2+Y.^2); %rasius k=1; % wave vector phi=0; % phase Z=sin(k*R+phi); surf(X,Y,Z); axis equal;

  0 Comments

Sign in to comment.


Sean de Wolski
Sean de Wolski on 28 Mar 2012
I'm not really clear on what you want:
This:
surf(bsxfun(@(x,y)sin(x)+sin(y),-pi:0.1:pi,(-pi:0.1:pi)'))
or this:
surf(sin(repmat(-pi:0.1:pi,100,1)))
or maybe this?
surf(bsxfun(@(x,y)sin(x)+y,-pi:0.1:pi,(-pi:0.1:pi)'))
Please clarify your question if you want more detail.

  0 Comments

Sign in to comment.

Sign in to answer this question.

Tags


Translated by