Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot a point in 3D

Subject: plot a point in 3D

From: akle

Date: 11 Feb, 2009 08:24:40

Message: 1 of 9

hi ...

[x,y] = meshgrid(-2:.1:2, -2:.1:2);
z = x .* exp(-x.^2 - y.^2);
mesh(z)

with the help of these 3 lines of codes I see a surface. but how to view specific points in 3D

for example in 2D for function y = x I see specific points with
plot(1,1,'ro') plot(3,3,'ro') ...

how can I view a 3D surface and noticeable specific points on it ?

thank you

Subject: plot a point in 3D

From: Gavrilo Bozovic

Date: 11 Feb, 2009 08:39:02

Message: 2 of 9

akle <r_rukaplan_n@yahoo.ca> wrote in message <17197584.1234340710622.JavaMail.jakarta@nitrogen.mathforum.org>...
> hi ...
>
> [x,y] = meshgrid(-2:.1:2, -2:.1:2);
> z = x .* exp(-x.^2 - y.^2);
> mesh(z)
>
> with the help of these 3 lines of codes I see a surface. but how to view specific points in 3D
>
> for example in 2D for function y = x I see specific points with
> plot(1,1,'ro') plot(3,3,'ro') ...
>
> how can I view a 3D surface and noticeable specific points on it ?
>
> thank you

x=reshape(x,size(x,1)*size(x,2),1);
y=reshape(y,size(x,1)*size(x,2),1);
z=reshape(z,size(x,1)*size(x,2),1);

plot3(x,y,z,'ro');

It will work, but I'm not very happy with the first three lines, perhaps someone will have a better suggestion!

Subject: plot a point in 3D

From: Caroline From France

Date: 11 Feb, 2009 08:40:03

Message: 3 of 9

akle <r_rukaplan_n@yahoo.ca> wrote in message
>
> how can I view a 3D surface and noticeable specific points on it ?
>

Hi,

With PLOT3 function.
Example :
plot3(1,1,1,'marker','o')

Caroline

Subject: plot a point in 3D

From: Johannes Huth

Date: 11 Feb, 2009 08:45:03

Message: 4 of 9

"Gavrilo Bozovic" <gavrilo.dot.bozovic@helbling.dot.ch> wrote in message <gmu2r5$50m$1@fred.mathworks.com>...
> akle <r_rukaplan_n@yahoo.ca> wrote in message <17197584.1234340710622.JavaMail.jakarta@nitrogen.mathforum.org>...
> > hi ...
> >
> > [x,y] = meshgrid(-2:.1:2, -2:.1:2);
> > z = x .* exp(-x.^2 - y.^2);
> > mesh(z)
> >
> > with the help of these 3 lines of codes I see a surface. but how to view specific points in 3D
> >
> > for example in 2D for function y = x I see specific points with
> > plot(1,1,'ro') plot(3,3,'ro') ...
> >
> > how can I view a 3D surface and noticeable specific points on it ?
> >
> > thank you
>
> x=reshape(x,size(x,1)*size(x,2),1);
> y=reshape(y,size(x,1)*size(x,2),1);
> z=reshape(z,size(x,1)*size(x,2),1);
>
> plot3(x,y,z,'ro');
>
> It will work, but I'm not very happy with the first three lines, perhaps someone will have a better suggestion!



What about
% given x, y
z = x .* exp(-x.^2 - y.^2);
plot3(x,y,z,'ro');

?

Subject: plot a point in 3D

From: akle

Date: 12 Feb, 2009 07:14:07

Message: 5 of 9

Thank you very much. but when I type
[x,y] = meshgrid(-2:.1:2, -2:.1:2);
z = x .* exp(-x.^2 - y.^2);
mesh(z)
hold on
plot3(1,1,0.1353,'r*');
hold off

the point (1,1,0.1353) does not seem to be on the surface plotted by mesh. why?... I think mesh should satisfy all points of objective function ?

Subject: plot a point in 3D

From: us

Date: 12 Feb, 2009 07:46:04

Message: 6 of 9

akle
> when I type
> [x,y] = meshgrid(-2:.1:2, -2:.1:2);
> z = x .* exp(-x.^2 - y.^2);
> mesh(z)
> hold on
> plot3(1,1,0.1353,'r*');
> hold off
> the point (1,1,0.1353) does not seem to be on the surface plotted by mesh. why?... I think mesh should satisfy all points of objective function...

it does - but you do not use it correctly...

one of the solutions

     [x,y]=meshgrid(-2:.1:2, -2:.1:2);
     z=x.*exp(-x.^2 - y.^2);
     mesh(x,y,z); % <- note the difference
     hold on;
     plot3(1,1,0.1353,'sk','markerfacecolor',[0,0,0]);
     view(140,30);
     hold off;

us

Subject: plot a point in 3D

From: akle

Date: 12 Feb, 2009 11:12:23

Message: 7 of 9

thanks a lot. it works ;)

Subject: plot a point in 3D

From: Suhan Shetty

Date: 20 Apr, 2012 04:07:08

Message: 8 of 9

Thanks a lot . You made my things easier.

Subject: plot a point in 3D

From: Sidhant Pednekar

Date: 6 Jun, 2014 01:23:12

Message: 9 of 9

"Caroline From France" wrote in message <gmu2t3$92o$1@fred.mathworks.com>...
> akle <r_rukaplan_n@yahoo.ca> wrote in message
> >
> > how can I view a 3D surface and noticeable specific points on it ?
> >
>
> Hi,
>
> With PLOT3 function.
> Example :
> plot3(1,1,1,'marker','o')
>
> Caroline

THANK YOU!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us