Hist3 zero enteries

1 回表示 (過去 30 日間)
Ankita Gupta
Ankita Gupta 2022 年 11 月 19 日
コメント済み: Steven Lord 2022 年 11 月 20 日
I have the following code which gives me
x1=load('file1.txt');
x2=load('file2.txt');
bin_x = linspace(0,1,100);
bin_y = linspace(0,1,100);
X=[x1 x2];
[cnt,c]=hist3(X,{bin_x,bin_y})
cnt=cnt/sum(cnt,'all');
[x,y] = meshgrid(bin_x,bin_y);
f=figure
sc=surfc(x,y,cnt)
which gives me
when I view this using axis([0 1 0 1]) in 2D plane it gives me
I want the change the color of blue area in surf plot to some lighter color and in 2D plot, I want to remove the blue colored area, how do I do that.

回答 (1 件)

Steven Lord
Steven Lord 2022 年 11 月 19 日
Instead of using hist3 I recommend you use histogram2 instead. It has some properties, including Normalization and ShowEmptyBins, that you may find useful.
  2 件のコメント
Ankita Gupta
Ankita Gupta 2022 年 11 月 20 日
I used histogram2 it shows the follwoing error.
>> histogram2(X)
Error using histogram2>parseinput (line 230)
X and Y inputs must be numeric or logical and they must have the same size.
Error in histogram2 (line 144)
[opts,args,vectorinput] = parseinput(args, firstaxesinput);
Steven Lord
Steven Lord 2022 年 11 月 20 日
hist3 and histogram2 are not called with exactly the same input arguments. You will need to modify your code to replace calls to hist3 with calls to histogram2 and then modify the input argument list in your histogram2 call. See the histogram2 documentation page for the allowed calling sequences and examples of how to call it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by