# 3D plot problem

I have a matrix $(A_{10*10})$ in which each elements of matrix states the value of the function $y=f(x,y)$. Since, $y$ shows the enclosed area between two squares, so I don't have the value of these elements in this area. Now my question is that how can I plot the $y$ in termes of $x,y$ in 2D or 3D using matlab while I don't have the values of $y$ in $A(3:5,3:5)$? Thank you in advance.

-

put your data instead of A matrice

 A=rand(10,10);
h = bar3(A);
colormap jet
colorbar


for change in color you can use this code :

 shading interp
for i = 1:length(h)
zdata = get(h(i),'ZData');
set(h(i),'CData',zdata)
set(h,'EdgeColor','k')
end


-

If you the values A(3:5,3:5) are undefined, set them to NaN and the plotting commands will ignore them. You can then use @AmirAlizadeh's approach with bar3, or draw an image with imagesc. The latter is perhaps less spectacular, but often clearer. In particular, with bar3 it would be hard to see the "hole" in x=3:5, y=3:5.

A=rand(10,10); % example data...
A(3:5,3:5) = NaN; % ...no data here
imagesc(A)
colorbar
axis xy
xlabel 'x'
ylabel 'y'


-

To see negative values during X-Y-View (view similar to imagesc) you can define a function like this to change the color of the bars corresponding to their height:

function make_bar3_scaled_color(h) %MAKE_BAR3_SCALED_COLOR changes the color of the bars in a BAR3 plot %corresponding to their heigths.

for i = 1:length(h)
zdata = get(h(i),'ZData');
size_zdata = size(zdata);
%zdata = ones(size_zdata);
for j=0:6:(size_zdata(1)-6)
akt_data = zdata(j+1:j+6,:);
[max_akt_data max_pos] = max(abs(akt_data(:)));
zdata(j+1:j+6,:) = akt_data(max_pos);
end
set(h(i),'CData',zdata);
end


end

-