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:
XYZ coordinate from a 2d matriz

Subject: XYZ coordinate from a 2d matriz

From: Rafael

Date: 22 Mar, 2011 18:56:06

Message: 1 of 2

i have this 2-D matrix
 A=[0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,21.4324000000000,28.4802000000000,25.8033000000000,0,0;0,0,28.7167000000000,38.1460000000000,35.0597000000000,22.7629000000000,0;0,0,35.4283000000000,46.9738000000000,43.5262000000000,28.6299000000000,0;0,0,40.4573000000000,53.5096000000000,49.8004000000000,33.0411000000000,0;0,0,42.8785000000000,56.5518000000000,52.7260000000000,35.1614000000000,0;0,0,42.1743000000000,55.4387000000000,51.6698000000000,34.5130000000000,0;0,0,38.3691000000000,50.2194000000000,46.6855000000000,31.0975000000000,0;0,0,32.0352000000000,41.6579000000000,38.5157000000000,25.4062000000000,0;0,0,24.1660000000000,31.0652000000000,28.4273000000000,0,0;0,0,0,20.0041000000000,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;0,0,0,0,0,0,0;]


This give me a surface, but i only have 2 axis X, Y, and the intensisty.
I would like to transform this 2-d matrix into a 3-d matrix or a matriz with 3 axis XYZ.
ex: x, y z =[ 0, 0, 0] , ....... x, y, z= [3, 7, 21.43].....
x() y() z()
0 0 0
1 1 0
1 2 0
.....
2 6 0
2 7 0
....
3 9 35.43
3 10 40.46
...
and on.......
So it can represent all points the surface and give me a 3-d plot

Subject: XYZ coordinate from a 2d matriz

From: Sadik

Date: 23 Mar, 2011 01:29:04

Message: 2 of 2

Hi Rafael,

You may try meshgrid to do that:

x = 1:7;
y = 1:22;

[X,Y] = meshgrid(x,y);
Z = A;
surf(X,Y,Z)

Best.

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