modified plotting in matlab?

2 ビュー (過去 30 日間)
Somnath Kale
Somnath Kale 2022 年 8 月 13 日
編集済み: Somnath Kale 2022 年 8 月 18 日
I have data for several histograms I am willing to plot like this one in attachenment using matlab. Is it possible in matlab of yes plese gauide
i have attached here 10*16 matrix data and on z axix i wanted to plot number of couts similar to that of verticle axis in 2d histogram plot
  4 件のコメント
Somnath Kale
Somnath Kale 2022 年 8 月 14 日
編集済み: Somnath Kale 2022 年 8 月 14 日
@Torsten Thank you fir you comment!
I aproch with bar3 aor scatterbar3 didnt work!
Is ther any other way to do it?

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

採用された回答

Asmit Singh
Asmit Singh 2022 年 8 月 16 日
編集済み: Asmit Singh 2022 年 8 月 16 日
I understand that you want to plot a 3D Histogram from a matrix. For any histogram plotting, we need to decide on a bin size, that is the size of the smallest unit on one axis to be considered for calculating counts on the z axis. As mentioned in this example, the sample code for generating a 3D histogram for 30X1000 matrix, with random real numbers between -5 and 5, and a bin size of 0.5 is as follows
%generating random data
data = zeros(30,1000);
for k = 1:30
data(k, :) = rand(1) + rand(1)*randn(1000, 1);
end
%defining bins
bins = [-5:0.5:5];
counts = histc(data, bins, 2);
%plotting
hf = figure;
ha = axes;
hb = bar3(bins, counts.');
xlabel('split 1')
ylabel('bins');
zlabel('count');
In your case, the matrix size is 16X10. You can recheck your matrix once, considering that each row has identical values across columns. Assuming a range of -1 and 1, with a bin size of 0.1. We can generate the 3D Histogram as follows
data = readmatrix("data.txt");
edges = [-1:0.1:1];
counts = histc(data, edges, 2);
hf = figure;
ha = axes;
hb = bar3(edges, counts.');
xlabel('split 1')
ylabel('bins');
zlabel('count');
You can change the bin size and the range as per your requirements.
Disclaimer : This answer is my personal idea, and has nothing to do with MathWorks
  1 件のコメント
Somnath Kale
Somnath Kale 2022 年 8 月 16 日
編集済み: Somnath Kale 2022 年 8 月 16 日
Thank you!@Asmit Singh
I have manged it similarly with the help of mathwork officials and your absolutly right that the data attached here is actully dummy one!
Thank you for your time efforts and suggetion!!

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

その他の回答 (0 件)

カテゴリ

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