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
| function main()
clc
clear
Z = [1 2 ; 3 4] ;
left = 1;
bottom = 1;
width = 3;
height = 3 ;
rect = [left, bottom, width, height] ;
figure('PaperUnits', 'centimeters', 'PaperSize', [5, 5], 'PaperPosition', rect)
hold off
subplot(2,2,1)
plot_barres(Z, 'y', 'b', 'b', 'r', 'b', 'r') ;
subplot(2,2,2)
plot_barres(Z, 'y', 'b', 'b', 'r', 'b', 'r') ;
subplot(2,2,3)
plot_barres(Z, 'y', 'b', 'b', 'r', 'b', 'r') ;
subplot(2,2,4)
plot_barres(Z, 'y', 'b', 'b', 'r', 'b', 'r') ;
end
function plot_barres(Z, top, bottom, f1, f2, f3, f4)
[X,Y] = meshgrid(1:size(Z, 2), 1:size(Z,1)) ;
for i = 1:numel(X)
barre(X(i), Y(i), Z(i), top, bottom, f1, f2, f3, f4) ;
end
end
function barre(x, y, z, top, bottom, f1, f2, f3, f4)
dx = [0,1,1,0] ;
dy = [0 0 1 1] ;
dz = [0 0 0 0] ;
X = x+dx ;
Y = y+dy ;
Z = z+dz ;
hold on
patch (x+dx-0.5,y+dy-0.5,z+dz,top) ; hold on
patch (x+dx-0.5,y+dy-0.5,z.*dz,bottom) ; hold on
patch(x+dy-0.5, y+dz-0.5, z.*dx, f1) ; hold on
patch(x+dy-0.5, y+dz+0.5, z.*dx, f2) ; hold on
patch(x+dz+0.5, y+dx-0.5, z.*dy, f3) ; hold on
patch(x+dz-0.5, y+dx-0.5, z.*dy, f4) ; hold on
end |
Partager