Create single array from multiple arrays in struct

7 ビュー (過去 30 日間)
Autumn P
Autumn P 2021 年 12 月 13 日
コメント済み: Autumn P 2021 年 12 月 14 日
HI, I am rather new to Matlab and am trying to perform some statistics on data I have in a structure. I have several hundred arrays of varying length for each index in the structure representing water levels from a storm (Storm.hydrograph). I want to be able to get the mean and standard deviation for all of the values from all storms. To do this, I am trying to generate a single list/array of all the water level points from every storm.
I have tried :
allHydro = [Storms.hydrograph]
but I get error messages because each of the arrays are of unique length.
Is there a way to get them all in one array? Or is there a way to perform statistics on them as they are in the structure? (I have already done statistics on them individually, but want statistics of all the values combined).
Thank you!
  2 件のコメント
Jan
Jan 2021 年 12 月 13 日
You have to clarify what you want to do mathematically. If the different arrays have different sizes, it ist not clear, what you want to do.
Storms(1).hydropgraph = 1:10
Storms(2).hydropgraph = 2:21
So what ou you wnt to achieve now? "Statistics over them" is not defined uniquely.
Autumn P
Autumn P 2021 年 12 月 14 日
They're all 1:n arrays. Where n varies. I want one big list of all the values and then I am going to get the mean and standard deviation of all said values.

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

採用された回答

cr
cr 2021 年 12 月 14 日
Presuming the error you got is "Dimensions of arrays being concatenated are not consistent.", all data in column vectors may be concatenated using
allHydro = cat(1,Storms.hydrograph);
  1 件のコメント
Autumn P
Autumn P 2021 年 12 月 14 日
Thank you! I knew it had to be simple, but I could not figure it out.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by