필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to vary colourmap while using surf function

조회 수: 1 (최근 30일)
Ricky
Ricky 2013년 8월 15일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello Everyone,
I am using surf command to plot a 2 dimensional function Z. The dimensions of Z are 155*125. The minimum value of Z is 162 and maximum value is 2048. I want to define my colour bar such that
values greater than 1301 -> colour black
values between 801 - 1300 -> colour red
values between 501 - 800 -> colour blue
values between 200 - 500 -> colour yellow
values less than 200 -> colour dark red
In the documentation i was able to find the RGB colours corresponding to my requirements, but I do not know how to generate a colourmap using the RGB values which fits my above mentioned criteria.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 8월 15일
Let darkred yellow and so on be rgb row vectors with the appropriate content. Then
cmap = vertcat( repmat(darkred, 200-162, 1), repmat(yellow, 500-200, 1), repmat(blue, 800-500, 1), repmat(red, 1300-800, 1), repmat(black, 2048-1300, 1));
colormap(cmap);

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by