필터 지우기
필터 지우기

How to represent a 2D plot using color plot

조회 수: 6 (최근 30일)
Dhruba jyoti Bora
Dhruba jyoti Bora 2020년 8월 11일
답변: Rik 2020년 8월 11일
I have the following two variables: x (it represent depth of a material from the surface), y (it represnt a variable which changes as the depth of the material increases)
x=[ 0 0.04 0.164 1 2 3 4 5 6 6.052 7 7.965 8 9 10 ]
y=[ 6201.67 8328.37 6201.67 3476.751 2432.011 1820.878 1387.272 1050.941 776.1486 763.13 543.7965 349.14 342.5326 165.0053 6.201674 ]
I have made a plot of y against y. However, it is required to made a color plot like varying color for y (based on its magnitude) as the depth increases ie. x. For high values of y a darker color which decreses as the value of y decreases. An example plot is attached below for illustration only. Please help me

채택된 답변

Rik
Rik 2020년 8월 11일
It is a bit more complicated than simply using surf, since you don't have 2D data, just a vector. There are probably other ways to make this, but this is an easy one. If you want to label your axes, note that y is now in the z-direction.
x=[ 0 0.04 0.164 1 2 3 4 5 6 6.052 7 7.965 8 9 10 ] ;
y=[ 6201.67 8328.37 6201.67 3476.751 2432.011 1820.878 1387.272 1050.941 776.1486 763.13 543.7965 349.14 342.5326 165.0053 6.201674 ];
surf([x(:) x(:)],ones(numel(x),2),[y(:) y(:)],...
'EdgeColor','interp')
view(90,0)
xlabel('x')
zlabel('y')

추가 답변 (0개)

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by