MATLAB: Gray Color Intensity fill.

color intensitycolormapgray colorImage Processing Toolboxshape

I need some assistance on the problem described below. I believe it is more clearer than the earlier post.
%% Problem Description.
% This code represent a 2D spray divided into 5 layers.
% X(SL) represent the axial length,Y(h), the radial length and Z represent the AFR(air-fuel-ratio).
% My intention is to generated a gray color intensity using the Z(AFR) matrix and then distribute
% it into these 5 zones instead of using the FaceColor "y,y,y,y,y" in the code.
% My attempt to use mat2gray,imagesc did not yield any fruit.
% The rsult should be real-time since the variables X,Y and Z are prone to change.
% (The data files for X,Y and Z currently used are attached)
% Color Intensity variation over area stack.
L=5;
for j=1:L % L is the number of layers.
X(j,:)=SL(j,:); % represent the axial length of spray zones
Y(j,:)=h(j,:); % axial length of spray zones
Z(j,:)=AFR(j,:); % Air -fuel Ratio
end
% I = mat2gray(Z,[0 max(max(Z))]);
% imshow(I, []);
Color=['y' 'y' 'y' 'y' 'y'];
figure(14)
hold on
for j=L:-1:1
Ar(j,:)=area(X(j,:)*1000,(Y(j,:)*1000),'FaceColor',Color(j));
Ar(j,:)=area(X(j,:)*1000,(Y(j,:)*1000)*-1,'FaceColor',Color(j));
end
axis([0 350 -100 100]);
grid on
box on
set(gca,'linewidth',1)
xlabel('X [mm]');
ylabel('Y [mm]')

Best Answer

Note that AFR should hav one less row as well as column.
Probably, the simplest way to create your spray:
pdata = surf2patch(SL, h, zeros(size(h), AFR(1:end-1, :)));
figure;
patch(pdata, 'FaceColor', 'flat', 'EdgeColor', 'none');
colormap(grey); %whatever colour map you want to use
surf2patch is used to convert your mesh into polygons that is then passed to patch.