Borrar filtros
Borrar filtros

Change color or surface and points above an upper limit using scatter3 and trisurf.

2 visualizaciones (últimos 30 días)
Hi all! I am having trouble with colormapping. I would like to make all points and surface below a user set upper limit to have the colormap jet, but points and surface above this limit be red. Here is my code so far.
X = [My data]
Y = [My data]
Z = [My data]
xlin = linspace(min(X), max(X), 100);
ylin = linspace(min(Y), max(Y), 33);
[x,y] = meshgrid(xlin,ylin);
a = [min(X), min(X), max(X), max(X)];
b = [min(Y), max(Y), max(Y), min(Y)];
c = [1.176, 1.176, 1.176, 1.176];
for k = 1 : length(Z)
if Z(k) > 1.176
colorMap(k, :) = [1,0,0]; % Red
else
colorMap(k, :) = colormap(jet);
end
end
z = griddata(X, Y, Z, x, y, 'cubic');
T = delaunay(x,y);
figure('Name','Minimum Voltage', 'NumberTitle','off')
trisurf(T,x,y,z)
h = trisurf(T,x,y,z);
set(h, 'edgealpha', 0.5);
axis tight; hold on
scatter3(X, Y, Z, colorMap, 'o', 'filled')
set(gca, 'xscale', 'log')
r = patch(a, b, c, 'r');
set(r, 'facealpha', 0.3)
I am getting errors:
Unable to perform assignment because the size of the left side is
1-by-3 and the size of the right side is 256-by-3.
Error in drawplot (line 18)
colorMap(k, :) = colormap(jet);
This is how far I have gotten.
Again. Surface pure red above upper plane, points pure red above upper plane. Thanks all, I am new to Matlab.

Respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by