plotting 3-D data in 2-D

조회 수: 4 (최근 30일)
Donald
Donald 2011년 6월 15일
Hi again,
I have a 3D matrix (test=rand(3,3,4)) and I'm trying to plot each 2D entry through the third dimension [i.e. plot nine lines: (1,1,:),(1,2,:) and so on]. I'm not exactly sure how to do this, and can't get it to work with plot or plot3.
Any ideas?
Thanks,
Don

채택된 답변

Sean de Wolski
Sean de Wolski 2011년 6월 15일
test = repmat(magic(3),[1 1 4]); %each vector into the third dimension will be the same (so we can verify accuracy)
test2 = reshape(permute(test,[3 2 1]),size(test,3),[]); %permute it and reshape it so that each column represents one vector into the third dimension
plot(test2) %plot it
  댓글 수: 5
Donald
Donald 2011년 6월 21일
I've been fiddling around with this code and was wondering, is there a way to print the data from each row on a separate graphs? So for this 3x3 matrix have the output 3 charts with three lines each.
Sean de Wolski
Sean de Wolski 2011년 6월 21일
doc subplot
and then a for loop to do the work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by