필터 지우기
필터 지우기

how to color the difference between two variables specifing the colors

조회 수: 1 (최근 30일)
Michela
Michela 2015년 12월 24일
답변: Image Analyst 2015년 12월 24일
Hello, I am a beginner user of this very useful (but, for me, weird :-) ) software. As far, I have not so many problems, but now I need to create a figure in which I have two lines (one for each column of my matrix pM) and the area inside these lines has to be colored in red if the difference between the value of the two columns is negative, in blue otherwise. In other words, i=pM(:,1)-pM(:,2) if i<0 the area between pM(:,1) and pM(:,2) is red. How can I implement it in matlab???? Thank you!

답변 (1개)

Image Analyst
Image Analyst 2015년 12월 24일
Here's a start:
pM = rand(20, 2)
col1 = pM(:, 1);
col2 = pM(:, 2);
area(col1, 'FaceColor', 'b');
hold on;
area(col2, 'FaceColor', 'r');
legend('col1', 'col2');
minY = min([col1,col2], [], 2)
area(minY, 'FaceColor', 'w');
plot(col1, 'bo-', 'LineWidth', 2);
plot(col2, 'rd-', 'LineWidth', 2);
grid on;
If you want it to follow the slants, then you're going to have to increase the sampling so that you have data there.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by