Determine amount of items in Dataset

11 ビュー (過去 30 日間)
Cory Dinkle
Cory Dinkle 2022 年 2 月 18 日
回答済み: Cory Dinkle 2022 年 4 月 21 日
Hello, I am trying to write a simple script that removes all but the final "item" in a Dataset. Not sure if this would be called an element, so it's "item" in quotes. Attached is an image of a Dataset with 9+ of these items. When I try numel or size, I simply get "1". How do I find the number of items? Thanks in advance!

採用された回答

Cory Dinkle
Cory Dinkle 2022 年 4 月 21 日
numElements()

その他の回答 (1 件)

Esha Chakraborty
Esha Chakraborty 2022 年 2 月 21 日
Hi Cory,
I understand that you are trying to find the number of elements in a dataset array, say A, and numel(A) returns 1. To find the number of elements, n, in the dataset array A, use prod(size(A)) or numel(A,':',':').
However, the MATLAB “table” data type is recommended to work with heterogenous data instead of the “dataset” data type.
You can refer to the documentation for “numel” here.
  1 件のコメント
Cory Dinkle
Cory Dinkle 2022 年 2 月 24 日
編集済み: Cory Dinkle 2022 年 2 月 24 日
Hello Esha, thank you for the response. I am working with very large Simulink files and the option of using a table instead of a dataset is not available. The datasets are the "out.xFinal" of a simulation.
Also, this returns a value of "1", not the number of items within the Dataset. Please test your answer in a test case for verification first. I would recommend creating a simple simulation and looking at "out.xFinal" to see what I am referring to.

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

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by