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

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

From: Krithika

Date: 23 Nov, 2009 00:37:02

Message: 1 of 10

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?

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

From: kinor

Date: 23 Nov, 2009 09:30:18

Message: 2 of 10

"Krithika " <venkatkv@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

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

From: Krithika

Date: 23 Nov, 2009 18:39:20

Message: 3 of 10

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.removethiswithdot@gmx.de> wrote in message <hedkna$490$1@fred.mathworks.com>...
> "Krithika " <venkatkv@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

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

From: someone

Date: 23 Nov, 2009 20:35:18

Message: 4 of 10

"Krithika " <venkatkv@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.)

>
> "kinor " <kinor.removethiswithdot@gmx.de> wrote in message <hedkna$490$1@fred.mathworks.com>...
> > "Krithika " <venkatkv@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

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

From: Krithika

Date: 23 Nov, 2009 21:05:17

Message: 5 of 10

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


        

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

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

From: someone

Date: 23 Nov, 2009 21:46:19

Message: 6 of 10

"Krithika " <venkatkv@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.

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

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

From: Krithika

Date: 23 Nov, 2009 22:41:03

Message: 7 of 10

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.


>
> % 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.
>

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

From: Krithika

Date: 25 Nov, 2009 00:10:25

Message: 8 of 10

Does anybody has any suggestion as to how to superimpose the axis properties? this should get me my desired result

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

From: Steven Lord

Date: 30 Nov, 2009 03:55:14

Message: 9 of 10


"Krithika " <venkatkv@ymail.com> wrote in message
news: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?

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
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

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

From: Luigi Giaccari

Date: 8 Dec, 2009 12:20:20

Message: 10 of 10

"Krithika " <venkatkv@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"

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
plotting for 3d... Will Huang 25 Nov, 2009 12:44:41
rssFeed for this Thread

Contact us at files@mathworks.com