how to use the 'histfit' function for cell arrays?

7 ビュー (過去 30 日間)
Fercho_Sala
Fercho_Sala 2021 年 6 月 3 日
編集済み: Walter Roberson 2024 年 2 月 22 日
Hello, probably this is an easy question, however I was wondering how to use the ´histfit´ function for a cell array in order to plot the data by cells (in one general plot) delimited in the X axis by the cell number? Data attached, the code showed here just plot the entire cell array , without making a difference between cells. , Thank you.
histfit(S7{1,end});
  9 件のコメント
Fercho_Sala
Fercho_Sala 2021 年 6 月 3 日
@Scott MacKenzie is there another way to plot a whole histogram of S7 without using a loop?
Scott MacKenzie
Scott MacKenzie 2021 年 6 月 3 日
@Fercho_Sala Not that I'm aware of

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

回答 (1 件)

vidyesh
vidyesh 2024 年 2 月 22 日
編集済み: Walter Roberson 2024 年 2 月 22 日
Hello,
I understand that you're looking to create a histogram for all the values within your cell array ‘S7’ combined, and you're aiming for a solution that avoids loops, ideally condensing it into a single line of code.
This can be achieved by concatenating all cell contents vertically using ‘cat(1, S7{:})’, which stacks the data from each cell into a single column vector. Then, we can apply histfit directly to this vector. Here's the streamlined code:
load('S7.mat')
histfit(cat(1,S7{:}),10)
For more details on the cat function and its usage, you can refer to the following link: https://www.mathworks.com/help/matlab/ref/double.cat.html
Hope this helps

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by