필터 지우기
필터 지우기

surf won't display zeros in the last row?

조회 수: 1 (최근 30일)
Erik
Erik 2013년 7월 18일
I wanted to visualize binary vectors (of length 15) in black and white, so I wrote the following code to utilize surf:
vector = ones(1,15);
black = [1,5,14,15];
vector(black) = zeros(1,length(black));
fig_handle = figure;
surf([vector; vector]')
axis([1,2,1,16])
set(gca,'XTick',[])
set(gca,'XTickLabel',[])
set(gca,'YTick',[2,4,6,8,10,12,14])
set(gca,'YTickLabel',{'2','4','6','8','10','12','14'})
caxis([0 1])
colormap gray
view(0,270)
It works exactly as I want as long as "black" doesn't contain 15. When it does, no matter what I try, the fifteenth entry in the image remains white.
Suggestions? Thanks.

채택된 답변

Chad Gilbert
Chad Gilbert 2013년 7월 18일
The surf command is plotting from 1 to 15. If you want to show the width of the 15th block, you'll need to supply data up to 16. Changing your surf line to:
surf([1 2],1:16,[[vector; vector]'; [0 0]])
made your plot work for me. Also, if you want to create a 2D plot, as you are here, you can use pcolor instead of surf.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by