Filter löschen
Filter löschen

Is there any plot function that perform a plan view of bar3?

1 Ansicht (letzte 30 Tage)
mingcheng nie
mingcheng nie am 25 Feb. 2023
Beantwortet: DGM am 25 Feb. 2023
if we have a square matrix H=randi(N,N)+1i*randi(N,N); I want to see the plan view of bar3(abs(H)), especially, for the same amplitude of entries in H, I want them have the same color. By the way, I don't think pcolor will work because pcolor plot the abs(H) at grid point instead of square area.

Antworten (1)

DGM
DGM am 25 Feb. 2023
This sounds like a use for imagesc(). While surf()/pcolor() associate the data values with the vertices, image()/imagesc() associate the data with the face centers.
N = 5;
H = magic(5)
H = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
% a bar3 plot with bar colors matching z-height
hb = bar3(abs(H));
for k = 1:numel(hb)
c = permute(reshape(hb(k).ZData,6,5,4),[1 3 2]);
c = permute(repmat(max(c,[],[1 2]),[6 4 1]),[1 3 2]);
hb(k).CData(:) = reshape(c,[],4);
end
% using imagesc() instead
figure
imagesc(H)
Of course, if you want the gaps between the faces, that might be a different story.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by