×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How can I plot a 2D gauss function

How can I plot a 2D gauss function

How can I plot a 2D gauss function

(OP)
I'm trying to plot or get a surface of this 2D gaussian function.
h = A * exp(-s^2/S) * exp(t^2/T)

where
   s = x*cos(alpha) + y*sin(alpha) -r;
   t = -x*sin(alpha) + y*cos(alpha);

A, , r, S, T, alpha are given!!!!

I'm new to matlab and is not sure which plotting function to use or even how to write a program to do it

RE: How can I plot a 2D gauss function

(OP)
I've tried something like this but ..DOoH!!!
Not the result I was hoping for.

****** CODE ******
r = 5;
teta = 0;
Amax = 611;
As = 0.255;
At = 0.2068;
x = [0:10];
y = [0:10];
[X, Y] = meshgrid(x,y);

    s = (X.*cos(teta)) + (Y.*sin(teta)) -r;
    t = -X.*sin(teta) + Y.*cos(teta);
    %[S, T] = meshgrid(s, t);
    
    h = (exp(-(s^2/As)))*(exp(-(t^2/At)))*Amax;
   meshz(X, Y, h);

***** END CODE ******

RE: How can I plot a 2D gauss function

Try replacing this line

h = (exp(-(s^2/As)))*(exp(-(t^2/At)))*Amax;

with

h = (exp(-(s.^2./As)))*(exp(-(t.^2/.At))).*Amax;

M

--
Dr Michael F Platten

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources