Combining several sets of data in an array into one numeric array to make a histogram

I got 1826 set of data inside variable named X, each set of data inside has several numbers as data. I once use the variable to try making a histogram, but command window says only numeric array can achieve that. How can I transform all data into 1 numeric array and get the histogram. Thanks.

 採用された回答

Use vertcat to get the data into a column vector and then use histogram -
%Sample data
X = {rand(22,1); (1:22).'; primes(75).'}
X = 3×1 cell array
{22×1 double} {22×1 double} {21×1 double}
Y = vertcat(X{:})
Y = 65×1
0.1986 0.8357 0.4858 0.7844 0.3912 0.9759 0.7271 0.3676 0.2251 0.4418
%Direct call to histogram(), specify the bins as required
histogram(Y)

2 件のコメント

Yat Chi
Yat Chi 2023 年 12 月 29 日
Work perfectly, thanks for your help!
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 29 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Distribution Plots についてさらに検索

製品

リリース

R2023b

質問済み:

2023 年 12 月 29 日

コメント済み:

2023 年 12 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by