Color Proportional to Height in Scatter3()
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2011-8-4
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]);
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Color and Styling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!