Surf plot of minimum values of four matrices
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I have the following 4 matrices:
ZCV=[1 2 1 2;6 5 2 8;3 5 9 4; 11 2 0.5 6]; % yellow surf
ZBTmod=[5 2 9 4;1 2 0.2 9;10 9 5 7; 0.6 5 8.3 4]; % cyan surf
ZCD=[2 8 9 5;1 0.2 5 8;6 2 5 8; 0.6 9 8 7]; % red surf
ZCB=[6 2 6 2;2.3 6 7.3 5;4 4 4 6; 0.1 2 8 6]; % blue surf
I would like to plot a surf of minimum values of these 4 matrices with view (0 90) such that the color of a portion of the surf is consistent with the color indicated above. Attached is a sketch of my idea:
0 Kommentare
Akzeptierte Antwort
DGM
am 22 Mär. 2023
Bearbeitet: DGM
am 22 Mär. 2023
I don't know how you intend to get that plot from that data, but maybe your actual data has more resolution.
ZCV=[1 2 1 2;6 5 2 8;3 5 9 4; 11 2 0.5 6]; % yellow surf
ZBTmod=[5 2 9 4;1 2 0.2 9;10 9 5 7; 0.6 5 8.3 4]; % cyan surf
ZCD=[2 8 9 5;1 0.2 5 8;6 2 5 8; 0.6 9 8 7]; % red surf
ZCB=[6 2 6 2;2.3 6 7.3 5;4 4 4 6; 0.1 2 8 6]; % blue surf
% stack the arrays
ZZ = cat(3,ZCV,ZBTmod,ZCD,ZCB);
% find the minimum values and the corresponding source index
[Z idx] = min(ZZ,[],3);
% if all that's desired is a flat-colored image
% then there's no need for surf() or the Z data
% just generate an image from the indices and the colormap
CT = [1 1 0;
0 1 1;
1 0 0;
0 0 1];
outpict = ind2rgb(idx,CT);
% image has the same size as the Z data
imshow(outpict)
3 Kommentare
Weitere Antworten (1)
Steven Lord
am 22 Mär. 2023
Create the four surfaces.
ZCV=[1 2 1 2;6 5 2 8;3 5 9 4; 11 2 0.5 6]; % yellow surf
surf(ZCV, FaceColor = "y")
hold on
ZBTmod=[5 2 9 4;1 2 0.2 9;10 9 5 7; 0.6 5 8.3 4]; % cyan surf
surf(ZBTmod, FaceColor = "c")
ZCD=[2 8 9 5;1 0.2 5 8;6 2 5 8; 0.6 9 8 7]; % red surf
surf(ZCD, FaceColor = "r")
ZCB=[6 2 6 2;2.3 6 7.3 5;4 4 4 6; 0.1 2 8 6]; % blue surf
surf(ZCB, FaceColor = "b")
Look at the axes from below.
view([0 0 -1]) % or view(0, -90)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!