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 plot from 2D plot

Subject: 3D plot from 2D plot

From: Lorenzo

Date: 18 Sep, 2008 22:32:18

Message: 1 of 7

Hi;
I've got many wavelet spectra and I need to put them in the same plot in order to compare them. I could just superimpose them in a 2D plot, but that would be chaotic so I'd like to create a 3D plot by putting every spectrum next to another. For example I could have Power Spectral Density on the Y axis, Frequencies on the X axis and plot a different spectrum every, say, 0.5 Z.
I don't know if I make myself clear...
Any idea?
Thanx
Lorenzo

Subject: 3D plot from 2D plot

From: Walter Roberson

Date: 18 Sep, 2008 23:17:38

Message: 2 of 7

Lorenzo wrote:
> Hi;
> I've got many wavelet spectra and I need to put them in the same plot in order
> to compare them. I could just superimpose them in a 2D plot, but that would be
> chaotic so I'd like to create a 3D plot by putting every spectrum next to another.

%adjust the 0.5 as necessary, you could probably just use plain K with no multiplier
calcZ = @(X,K) repmat(0.5 * K, 1, length(X{K}));

for K = 1:NumSpectra
  line(X{K}, Y{K}, calcZ(X,K));
end

Subject: 3D plot from 2D plot

From: Lorenzo

Date: 19 Sep, 2008 08:54:58

Message: 3 of 7

Sorry, but I couldn't run it as I couldn't "undestand" how it works.

I have many variables(e.g. A1,A2,A3...) that contain, say, frequencies on the 1st column and wavelet power density on the 2nd column. So I have to plot, e.g. A1(:,1),A1(:,2) and z=0.5; A2(:,1),A2(:,2) and z=1 and so on...
Actually I just need a command to do that for one variable and then I'll find a way to do that for al my variables automatically.
Could You help me once again please?
Thanx

Subject: 3D plot from 2D plot

From: Yuri Geshelin

Date: 19 Sep, 2008 14:07:01

Message: 4 of 7

Lorenzo <liquidcrystal@tiscali.it> wrote in message <26882883.1221814529235.JavaMail.jakarta@nitrogen.mathforum.org>...
> Sorry, but I couldn't run it as I couldn't "undestand" how it works.
>
> I have many variables(e.g. A1,A2,A3...) that contain, say, frequencies on the 1st column and wavelet power density on the 2nd column. So I have to plot, e.g. A1(:,1),A1(:,2) and z=0.5; A2(:,1),A2(:,2) and z=1 and so on...
> Actually I just need a command to do that for one variable and then I'll find a way to do that for al my variables automatically.
> Could You help me once again please?
> Thanx

Hi,

Walter's point is, you have to use function 'line' to make a 3-D plot. The following example may help you, as it is more like in terms you are thinking:

x = 1 : 100; y = sin(.1*x);
A1=[x' y'+1];
A2=[x' y'+2];
A3=[x' y'+3];
A4=[x' y'+4];
s = ones(size(A1(:,1)));
close all
line(s*0.5,A1(:,1),A1(:,2))
line(s*1.0,A2(:,1),A2(:,2))
line(s*1.5,A3(:,1),A3(:,2))
line(s*2.0,A4(:,1),A4(:,2))
set(gca,'CameraPosition',[10 180 25])

Yuri

Subject: 3D plot from 2D plot

From: Yuri Geshelin

Date: 19 Sep, 2008 14:12:04

Message: 5 of 7

Lorenzo <liquidcrystal@tiscali.it> wrote in message <26882883.1221814529235.JavaMail.jakarta@nitrogen.mathforum.org>...
> Sorry, but I couldn't run it as I couldn't "undestand" how it works.
>
> I have many variables(e.g. A1,A2,A3...) that contain, say, frequencies on the 1st column and wavelet power density on the 2nd column. So I have to plot, e.g. A1(:,1),A1(:,2) and z=0.5; A2(:,1),A2(:,2) and z=1 and so on...
> Actually I just need a command to do that for one variable and then I'll find a way to do that for al my variables automatically.
> Could You help me once again please?
> Thanx

Having understood my exmaple, you better switch to Walter's suggestion. It isn't a good programming style to deal with arrays A1, A2, ... Use cell arrays instead.

Yuri

Subject: 3D plot from 2D plot

From: Lorenzo

Date: 19 Sep, 2008 19:56:31

Message: 6 of 7

Ok, thanx to both of you!
Lorenzo

Subject: 3D plot from 2D plot

From: Boris

Date: 19 Sep, 2008 23:54:02

Message: 7 of 7

Lorenzo <liquidcrystal@tiscali.it> wrote in message <15737133.1221854222482.JavaMail.jakarta@nitrogen.mathforum.org>...
> Ok, thanx to both of you!
> Lorenzo
Hi Lorenzo
Cannot you just put them one after another and use imagesc (chose hot or jet colormap), you could use also surf (in 3D view you going to have to turn it so you would be kinda looking at it from above). That's what I do with mine.
Boris

Tags for this Thread

No tags are associated with 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