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:
3d plotting

Subject: 3d plotting

From: Snow White

Date: 4 May, 2010 12:17:05

Message: 1 of 5

I have to plot a surface using 3d plotting. I have three vectors X,Y and N1

Sizeof X is 1 330
Sizeof Y is 1 320
Size of N1 is 330 320

i am trying meshgrid and surf but i get the following error:
surf(X,Y,N1)
??? Error using ==> surf at 70
Data dimensions must agree.

Subject: 3d plotting

From: Sean

Date: 4 May, 2010 12:36:12

Message: 2 of 5

"Snow White" <gulesaman@gmail.com> wrote in message <hrp381$o77$1@fred.mathworks.com>...
> I have to plot a surface using 3d plotting. I have three vectors X,Y and N1
>
> Sizeof X is 1 330
> Sizeof Y is 1 320
> Size of N1 is 330 320
>
> i am trying meshgrid and surf but i get the following error:
> surf(X,Y,N1)
> ??? Error using ==> surf at 70
> Data dimensions must agree.

x = 1:330;
y = 1:320;
N1 = rand(330,320);
[xx yy] = ndgrid(x,y);
surf(xx,yy,N1);

Here is an excerpt form the help of ndgrid:
  NDGRID is like MESHGRID except that the order of the first two input
    arguments are switched (i.e., [X1,X2,X3] = NDGRID(x1,x2,x3) produces
    the same result as [X2,X1,X3] = MESHGRID(x2,x1,x3)). Because of
    this, NDGRID is better suited to N-D problems that aren't spatially
    based, while MESHGRID is better suited to problems in cartesian
    space (2-D or 3-D).

Subject: 3d plotting

From: Wayne King

Date: 4 May, 2010 12:37:05

Message: 3 of 5

"Snow White" <gulesaman@gmail.com> wrote in message <hrp381$o77$1@fred.mathworks.com>...
> I have to plot a surface using 3d plotting. I have three vectors X,Y and N1
>
> Sizeof X is 1 330
> Sizeof Y is 1 320
> Size of N1 is 330 320
>
> i am trying meshgrid and surf but i get the following error:
> surf(X,Y,N1)
> ??? Error using ==> surf at 70
> Data dimensions must agree.

Hi, your 'X' vector has to match the size of N1 in along the column dimension. Your 'Y' vector has to match the size of N1 along the row dimension.

surf(X,Y,N1');

or swap your X and Y.

Wayne

Subject: 3d plotting

From: Snow White

Date: 4 May, 2010 17:29:06

Message: 4 of 5

thank you

"Wayne King" <wmkingty@gmail.com> wrote in message <hrp4dh$dov$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <hrp381$o77$1@fred.mathworks.com>...
> > I have to plot a surface using 3d plotting. I have three vectors X,Y and N1
> >
> > Sizeof X is 1 330
> > Sizeof Y is 1 320
> > Size of N1 is 330 320
> >
> > i am trying meshgrid and surf but i get the following error:
> > surf(X,Y,N1)
> > ??? Error using ==> surf at 70
> > Data dimensions must agree.
>
> Hi, your 'X' vector has to match the size of N1 in along the column dimension. Your 'Y' vector has to match the size of N1 along the row dimension.
>
> surf(X,Y,N1');
>
> or swap your X and Y.
>
> Wayne

Subject: 3d plotting

From: Luigi Giaccari

Date: 9 May, 2010 05:42:03

Message: 5 of 5

"Snow White" <gulesaman@gmail.com> wrote in message <hrp381$o77$1@fred.mathworks.com>...
> I have to plot a surface using 3d plotting. I have three vectors X,Y and N1
>
> Sizeof X is 1 330
> Sizeof Y is 1 320
> Size of N1 is 330 320
>
> i am trying meshgrid and surf but i get the following error:
> surf(X,Y,N1)
> ??? Error using ==> surf at 70
> Data dimensions must agree.


I hope one of these works

http://www.mathworks.com/matlabcentral/newsreader/create_message?reply_id=711429

http://www.advancedmcode.org/how-to-plot-a-coloured-surface-from-3d-scatter.html

http://www.advancedmcode.org/surface-recostruction-from-scattered-points-cloud-mycrustopen.html

http://www.advancedmcode.org/surface-recostruction-from-scattered-points-cloud-mycrust-robust.html



http://www.advancedmcode.org

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