Adding third dimenstion to 2D plot

I generated the following 2D plot:
<<http://i.stack.imgur.com/Bvt6W.jpg>>
The code I used for this looks as follows:
res = zeros(2, 320);
index = 1:320;
% assign some data to the res array and then approximate
PD = fitdist(index','normal', 'frequency', res(1,:)')
pdfNormal = normpdf(index',PD.mu,PD.sigma);
plot(index', pdfNormal, 'Color', 'r', 'LineWidth', 2);
hold on;
PD = fitdist(index','normal', 'frequency', res(2,:)')
pdfNormal = normpdf(index',PD.mu,PD.sigma);
plot(index', pdfNormal, 'Color', 'b', 'LineWidth', 2);
Now I am wondering how I could add a third dimension to this plot? Essentially, I would like to plot another 2 normal distributions, but this time in the Z-axis, ie., in the third dimension.
Anyone an idea how I could do that easily?
Thanks so much!

1 Comment

I've tried to remove the space before the embedded picture. But the picture too large to match in the borders. Therefore I've re-instered the space again.

Sign in to comment.

Answers (1)

Jan
Jan on 24 Jul 2012
Edited: Jan on 24 Jul 2012
z = repmat(0, numel(index), 1);
line(index', pdfNormal, z, 'Color', 'r', 'LineWidth', 2);
hold on;
...
z(:) = 1;
line(index', pdfNormal, z, 'Color', 'b', 'LineWidth', 2);
...
z(:) = 2;
line(index', pdfNormal, z, 'Color', 'g', 'LineWidth', 2);
...
view(3)

Categories

Find more on General Applications in Help Center and File Exchange

Asked:

on 24 Jul 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!