1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| clc
clear all
y = rand(9,100)*500-250;
s = sign(y);
figure(1)
clf
hold on
for m = 1:size(y,1)
v = [1 m-.4 ; size(y,2)+1 m-.4 ; size(y,2)+1 m+.4 ; 1 m+.4];
patch('vertices',v,'faces',[1 2 3 4],'facecolor','b');
n = 1;
k = 0;
while n<=size(y,2)
if s(m,n)==-1
idx = n;
k = k+1;
n = n+1;
if n>size(y,2)
break;
end
while s(m,n)==-1
k = k+1;
n = n+1;
if n>size(y,2)
break;
end
end
v = [idx m-.4 ; idx+k m-.4 ; idx+k m+.4 ; idx m+.4];
patch('vertices',v,'faces',[1 2 3 4],'facecolor','r','edgecolor','r');
idx = [];
k = 0;
else
n = n+1;
end
end
end
set(gca,'ytick',1:size(y,1));
axis tight |
Partager