Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

3d plot for an mxn matrix, different x, y indices

1 view
Skip to first unread message

Krithika

unread,
Nov 22, 2009, 7:37:02 PM11/22/09
to
I have an m x n matrix where the m denotes values obtained at different angles from 0 to 350, and n denotes the values obtained at different frequencies ranging from 20Khz to 20Hz. I am successfully able to plot the matrix in 3d using surf. But my x-axis and y-axis do not represent the angle and the frequency correctly, it just shows integer numbers from 1:m and 1:n .

My basic question is this: Is there any way in which I can plot the matrix using surf.m and indicate the actual angle and frequency values, instead of integer values?

kinor

unread,
Nov 23, 2009, 4:30:18 AM11/23/09
to
"Krithika " <venk...@ymail.com> wrote in message <heclfe$lm4$1...@fred.mathworks.com>...

> I have an m x n matrix where the m denotes values obtained at different angles from 0 to 350, and n denotes the values obtained at different frequencies ranging from 20Khz to 20Hz. I am successfully able to plot the matrix in 3d using surf. But my x-axis and y-axis do not represent the angle and the frequency correctly, it just shows integer numbers from 1:m and 1:n .
>
> My basic question is this: Is there any way in which I can plot the matrix using surf.m and indicate the actual angle and frequency values, instead of integer values?

help meshgrid
help plot3

Krithika

unread,
Nov 23, 2009, 1:39:20 PM11/23/09
to
meshgrid and plot3 do not help, as both require the length of X,Y, Z to be the same. In my case, mxn matrix is not a square matrix.
I am able to plot my matrix with surf. But it does not allow me to indicate the value of frequency or angle. It just displays the value for 1st frequency, 2nd frequency and so on.. but I want it to display for 20000Hz, for 19000 Hz.
Is there any solution to this?

"kinor " <kinor.remov...@gmx.de> wrote in message <hedkna$490$1...@fred.mathworks.com>...

someone

unread,
Nov 23, 2009, 3:35:18 PM11/23/09
to
"Krithika " <venk...@ymail.com> wrote in message <heekso$1qi$1...@fred.mathworks.com>...

> meshgrid and plot3 do not help, as both require the length of X,Y, Z to be the same. In my case, mxn matrix is not a square matrix.
> I am able to plot my matrix with surf. But it does not allow me to indicate the value of frequency or angle. It just displays the value for 1st frequency, 2nd frequency and so on.. but I want it to display for 20000Hz, for 19000 Hz.
> Is there any solution to this?

% Yes, use meshgrid.
% meshgrid does NOT require the length of its INPUTS to be the same.

doc meshgrid

% and see the Examples section.
% (The OUTPUTS of meshgrid are matricies of the same size.)

Krithika

unread,
Nov 23, 2009, 4:05:17 PM11/23/09
to
Unfortunately, meshgrid does not suit my purpose. I know how to plot my matrix. It is just that for my x-axis and y-axis, I do not want the integer values, I want to specify the proper angle and frequency the values correspond to. so for example, if i have my matrix as
1 2 3 4
5 6 7 8

value 1 corresponds to frequency 20Khz and angle 0deg
2 20Khz 10 deg
3 20Khz 20 deg

...

5 19Khz 0 deg
6 19 Khz 10 deg

and so on...
I can plot this matrix using surf.m But the xaxis ranges from 1:4 and the yaxis ranges from 1:2.

I want to show in the diagram that x axis is from 0 - 30 deg and y axis from 20 - 19Khz.

Is there a way to do this?

Thanks
KV

someone

unread,
Nov 23, 2009, 4:46:19 PM11/23/09
to
"Krithika " <venk...@ymail.com> wrote in message <heeted$1ic$1...@fred.mathworks.com>...

> Unfortunately, meshgrid does not suit my purpose. I know how to plot my matrix. It is just that for my x-axis and y-axis, I do not want the integer values, I want to specify the proper angle and frequency the values correspond to. so for example, if i have my matrix as
> 1 2 3 4
> 5 6 7 8
>
> value 1 corresponds to frequency 20Khz and angle 0deg
> 2 20Khz 10 deg
> 3 20Khz 20 deg
>
> ...
>
> 5 19Khz 0 deg
> 6 19 Khz 10 deg
>
> and so on...
> I can plot this matrix using surf.m But the xaxis ranges from 1:4 and the yaxis ranges from 1:2.
>
> I want to show in the diagram that x axis is from 0 - 30 deg and y axis from 20 - 19Khz.
>
> Is there a way to do this?

% Yes, use the xlim & ylim commands.

doc xlim
doc ylim

% Something like (after plotting):

xlim([0 30])
ylim([19 20])

% or set the axes properties for XLim, YLim, XDir directly

set(gca,'YDir', 'reverse')

% There are many other axes properties you can set as well.

doc axes

% shoul get you started.

Krithika

unread,
Nov 23, 2009, 5:41:03 PM11/23/09
to
xlim and ylim do not give me my desired results, either. As per my above example, x axis has 4 values and y axis has 2 values. If I give xlim([0 30]), it displays the x axis from 0 to 30. I do not want the graph / limits to change. I just need to display the xlabel and ylabel as ranging from 0 - 30 and from 20 - 19 Khz respectively.

Krithika

unread,
Nov 24, 2009, 7:10:25 PM11/24/09
to
Does anybody has any suggestion as to how to superimpose the axis properties? this should get me my desired result

Steven Lord

unread,
Nov 29, 2009, 10:55:14 PM11/29/09
to

"Krithika " <venk...@ymail.com> wrote in message
news:heclfe$lm4$1...@fred.mathworks.com...

It sounds like you're calling SURF with just one input -- if so take a look
in the help for the 3-input syntax, which allows you to specify the x- and
y- coordinates at which the surface "cells" should be plotted.

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


Luigi Giaccari

unread,
Dec 8, 2009, 7:20:20 AM12/8/09
to
"Krithika " <venk...@ymail.com> wrote in message <heclfe$lm4$1...@fred.mathworks.com>...

> I have an m x n matrix where the m denotes values obtained at different angles from 0 to 350, and n denotes the values obtained at different frequencies ranging from 20Khz to 20Hz. I am successfully able to plot the matrix in 3d using surf. But my x-axis and y-axis do not represent the angle and the frequency correctly, it just shows integer numbers from 1:m and 1:n .
>
> My basic question is this: Is there any way in which I can plot the matrix using surf.m and indicate the actual angle and frequency values, instead of integer values?

Triangulate using this:
http://www.advancedmcode.org/structured-triangular-mesh-generation.html

then plot using "trisurf"

0 new messages