putting a plot as different slices on an axis

조회 수: 5 (최근 30일)
Zahra Sheikhbahaee
Zahra Sheikhbahaee 2021년 1월 20일
댓글: Cris LaPierre 2021년 1월 20일
I want to use matlab to plot in different time-steps an agent who is moving to different places in this structure:
pgon = polyshape([-0.5 -0.6882; 0.5 -0.6882; 0.5 -1.6882;-0.5 -1.6882]);
pgon2 = polyshape([0.5 -0.6882; 0.806 0.2629; 1.7571 -0.0431;1.4511 -0.9972]);
pgon3 = polyshape([0.806 0.2629; 0 0.8507; 0.5878 1.6567;1.3938 1.0689]);
pgon4 = polyshape([0 0.8507; -0.809 0.2629; -1.3968 1.1136;-0.5878 1.6597]);
pgon5 = polyshape([ -0.809 0.2629; -0.5 -0.6882; -1.4511 -0.9972;-1.7601 -0.0461]);
plot([pgon1 pgon pgon2 pgon3 pgon4 pgon5]);
axis equal;
Now I have an array of positions for these 6 cells and I want to put this sturcture (if it is possible) as different slices in an axis so for N=20 then I can color code where my agent stands in this structure at each n. It would be like a 3D structure that allows me to see the positions in each n=1,..,20 in this plotted structure. Is it possible to do it?

채택된 답변

Cris LaPierre
Cris LaPierre 2021년 1월 20일
One thought is to create your geometry using patches, which allow you to specify a z coordinate.
pgon1 = [-0.5 -0.6882; 0.5 -0.6882; 0.5 -1.6882;-0.5 -1.6882];
pgon2 = [0.5 -0.6882; 0.806 0.2629; 1.7571 -0.0431;1.4511 -0.9972];
pgon3 = [0.806 0.2629; 0 0.8507; 0.5878 1.6567;1.3938 1.0689];
pgon4 = [0 0.8507; -0.809 0.2629; -1.3968 1.1136;-0.5878 1.6597];
pgon5 = [ -0.809 0.2629; -0.5 -0.6882; -1.4511 -0.9972;-1.7601 -0.0461];
patch(pgon1(:,1),pgon1(:,2),ones(length(pgon1),1),'r')
patch(pgon2(:,1),pgon2(:,2),ones(length(pgon2),1)*2,'y')
patch(pgon3(:,1),pgon3(:,2),ones(length(pgon3),1)*3,'g')
patch(pgon4(:,1),pgon4(:,2),ones(length(pgon4),1)*4,'b')
patch(pgon5(:,1),pgon5(:,2),ones(length(pgon5),1)*5,'m')
axis equal tight
view(3)
grid on
  댓글 수: 8
Zahra Sheikhbahaee
Zahra Sheikhbahaee 2021년 1월 20일
final question and I will appreciate a lot: How can I write a text in each cell of slices ?
Cris LaPierre
Cris LaPierre 2021년 1월 20일
I would probably attempt to do this using the text function.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by