필터 지우기
필터 지우기

Plotting data on a 2d plane with colorbar

조회 수: 27 (최근 30일)
Luffy
Luffy 2015년 10월 15일
댓글: Martin Schätz 2015년 10월 15일
I have 3 vectors of size 1:100 each(say X,Y,Z).I want to plot it on a 2d plane with colorbar indicating depth. I've tried with pcolor but it requires a matrix.
pcolor(X',Y',Z');
colorbar
Is this even correct way of doing it ?

답변 (2개)

Lessmann
Lessmann 2015년 10월 15일
Hi,
an easy way of doing this is the scatter plot. Use it like this
scatter(x,y,[],z,'filled')

Martin Schätz
Martin Schätz 2015년 10월 15일
Hey, in pcolor the X and Y means predefined grid (like from meshgrid ), and Z are actual data. So then X Y and Z has to be matrixes. If you have 1D X and Y and 2D Z then you can use meshgrid to generate 2D X and Y and use pcolor . If you had 1D Z, or all of your X Y Z are actual depth data, then you will have to display them as 1D data, or expand them to actual 2D array, create grid for them and use pcolor to display them. (And display colorbar as u did write in your answer.) Also check examples for pcolor they might help you to understad how this function works.
  댓글 수: 2
Luffy
Luffy 2015년 10월 15일
편집: Luffy 2015년 10월 15일
My data for example would be like this,
X = 750:5:1250;
Y = -50:50;
Z = -0.05:0.001:0.05
%all X,Y & Z are independent.
%Can i do
pcolor([X';Y';Z']) ?
Martin Schätz
Martin Schätz 2015년 10월 15일
You can just change the last line to this: pcolor([X;Y;Z]). But i dont think that this is what you wanted... Check it out in MatLab.

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by