Combine a number of vectors into a 2D color plot

조회 수: 4 (최근 30일)
Benjamin Westberry
Benjamin Westberry 2016년 2월 10일
댓글: Jos (10584) 2016년 2월 11일
I have a number of intensity profiles (saved as vectors) across the diameter of a laser beam, taken at increments along the length of the beam. I would like to generate a color plot similar to the one attached, with the vectors I have being vertical slices of this image. I have managed to get close using plot3 (second image attached) and setting hold on. With this approach the arguments of plot3 are a 1xn X vector of the distance along the diameter (same for each profile), a 1xn uniform Y vector for the increment along the beam (eg [2;2;2;2;2]), and a 1xn Z vector of the intensity. Is there some way to combine all the separate Z intensity vectors to produce an X,Y,intensity color plot, perhaps using pcolor?
  댓글 수: 2
Jos (10584)
Jos (10584) 2016년 2월 10일
Can you add axis labels and legend to your graphs?
Benjamin Westberry
Benjamin Westberry 2016년 2월 10일
편집: Benjamin Westberry 2016년 2월 10일
Hi, yes sorry here they are.
As for what I am trying to do, rather than a Z axis I would like a color map with the height corresponding to a color (the colors here are just generated by MATLAB and are not intended)

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

채택된 답변

Jos (10584)
Jos (10584) 2016년 2월 10일
Are all the vectors Zn of the same length? Then you can concatenate them into a single matrix with M rows (M is the number of slices/vectors) and N rows (N is the number of points along the slice).
You can create a surf plot an view it from the top, along these lines to:
surf(peaks)
view([0 90])
xlabel('X') ; ylabel('Y')
  댓글 수: 3
Benjamin Westberry
Benjamin Westberry 2016년 2월 11일
Your suggestion worked once I transposed each vector before appending to the matrix. Thanks a lot!
Jos (10584)
Jos (10584) 2016년 2월 11일
You're welcome.

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

추가 답변 (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