colorbar in 3d patch

4 views (last 30 days)
zawaiter
zawaiter on 6 Feb 2012
hi, iam using this function http://www.mathworks.cn/matlabcentral/fileexchange/28497-plot-a-3d-array-using-patch to plot 3D array,it did a great job,but since most of my data are in the range from 0 to 4,i wish i can edit the colorbar and fix it is upper and lower limits to 0 and 4,then any data value bigger than 4 mapped to 4,and data value less than zeros mapped to zero.i would like this change to compare my data values with color.plz some help

Answers (2)

Walter Roberson
Walter Roberson on 6 Feb 2012
How about if you use
DataToPlot = min( max(YourData, 0), 4);
This will restrict your data to that range before going in to the plotting routine, which would be easier than editing the plotting routine.

zawaiter
zawaiter on 7 Feb 2012
THANK YOU ROBERSON SO MUCH FOR ALL THE HELP,the problem is that my data have nans also and i want them to remain nans for 3d display.so i need something more like mydata(mydata > 4)=4; mydata(mydata < 0 && mydata ~=nan)=0; but i always get matlab error saying ??? Operands to the and && operators must be convertible to logical scalar values. any ideas?

Community Treasure Hunt

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

Start Hunting!