Color Proportional to Height in Scatter3()

6 visualizaciones (últimos 30 días)
Daniel
Daniel el 4 de Ag. de 2011
I am plotting data points in scatter3. The x and y coordinates are the location of a mirror, and the z value is the signal strength at that point. It ranges from 0 to 384.
I am trying to create a color array the same length as the data to be graphed in order to have different colors for the different heights. Right now I have this:
color=cell(384,1);
for j=1:384
if (signal{j} <40)
color(j)='r';
elseif (signal{j} >= 40) && (sigal{j} <100)
color(j)='g';
elseif signal{j} >=100
color(j)='b';
end
end
Basically I am trying to check the height of the point and based on the height, put a color code into a 384x1 array. However I keep getting this error code:
Cell contents reference from a non-cell array object. (It also points to this part:
if (signal{j} <40)
I am not sure why. The signal is a 384x1 double array.
Any help would be wonderful!

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Ag. de 2011
pointsize = 8;
[counts, ccode] = histc(signal,[-inf, 40, 100, inf])
scatter3(x,y,signal,pointsize,ccode(:));
colormap([1 0 0;0 1 0; 0 0 1]);

Más respuestas (1)

Daniel
Daniel el 4 de Ag. de 2011
Ok...I got this to work...messed with the formatting and stuff,
but now it doesnt like a colormap of the data. It says
Array must be numeric or logical.
My formatting for scatter3 is
scatter3(x,y,z,colormatrix)
where colormatrix is a 385x1 matrix with entries of 'r','g','b'
sorta like {'r','g'.....}
Any ideas?

Categorías

Más información sobre Color and Styling en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by