Color Proportional to Height in Scatter3()
6 views (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Walter Roberson
on 4 Aug 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]);
More Answers (1)
See Also
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!