how to have matlab give feedback if value in a table is outside of a given range

1 回表示 (過去 30 日間)
Nasir
Nasir 2019 年 6 月 18 日
コメント済み: Rik 2019 年 6 月 18 日
i have a matlab code that calculates some statistical values such as mean mode min and max values , each of which produces its own table of values. each table output has many columns (a coulumn for each variable to be looked at). how can i have matlab look at a specific column/variable for example in the "mean" table for any values less or more than 3 and 6 (arbitrary values) and give feedback or output a table of those values ?

採用された回答

Rik
Rik 2019 年 6 月 18 日
You mean with something like this?
x = gallery('integerdata',10,[5,1],2);
y = gallery('integerdata',10,[5,1],8);
A = table(x,y);
L=rowfun(@(x,y) x<3 | x>6,A,'OutputFormat','uniform');
  2 件のコメント
Nasir
Nasir 2019 年 6 月 18 日
can you explain the code , what each line or code exactly means , so that i can better understand how to use it ?
Rik
Rik 2019 年 6 月 18 日
The first 3 lines are taken from the documentation for the rowfun function. A quick glance at the documentation of the gallery function shows that this generates some random integer data, which is just what I needed to get some example data.
Then the rowfun call: it applies some function to each row of a table (or timetable). That means that in this case my anonymous function @(x,y) x<3 | x>6 is applied to every row. The output switch specifies that I want the output as a separate variable, not as a table column. The function itself returns true if x is smaller than 3 or larger than 6 (and false otherwise).

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by