从表中的每列中提取最大值(Extracting max value from each column in a table)

编程入门 行业动态 更新时间:2024-10-28 18:29:32
从表中的每列中提取最大值(Extracting max value from each column in a table)

我已经在一列中生成了一个包含时间的数据表,在下一系列列中尝试了1-10。 我希望能够在每次尝试中提取最大值以进行进一步分析。

我试过表MGA

max = max(MGA(:, []))

我得到以下错误 - “你不能只使用一个下标来下标表。表下标需要行和变量下标。”

I have generated a table of data with time in one column with attempts 1-10 in the next series of columns. I want to be able to extract the max value in each attempt for further analysis.

I have tried for table MGA

max = max(MGA(:, []))

I get the following error -- "You cannot subscript a table using only one subscript. Table subscripting requires both row and variable subscripts."

最满意答案

首先:永远不要做max = max(); ,你将超载max ,你将无法再次使用它。

要回答这个问题,您可以执行以下操作(请注意,我已将值保留在第一列中):

MGA MGA = 1 5 3 8 9 2 4 7 3 3 3 8 7 6 9 4 8 2 7 3 5 2 2 9 10 6 5 5 10 4 7 5 10 6 2 8 7 4 2 3 9 8 6 2 7 10 8 3 3 5 max_values = [MGA(:,1), max(MGA(:,2:end),[],2)] max_values = 1 9 2 7 3 9 4 8 5 10 6 10 7 10 8 7 9 8 10 8

First off: Never do max = max();, you'll overload max, and you won't be able to use it again.

And to answer the question, you can do as follows (notice that I've kept the values in the first columns):

MGA MGA = 1 5 3 8 9 2 4 7 3 3 3 8 7 6 9 4 8 2 7 3 5 2 2 9 10 6 5 5 10 4 7 5 10 6 2 8 7 4 2 3 9 8 6 2 7 10 8 3 3 5 max_values = [MGA(:,1), max(MGA(:,2:end),[],2)] max_values = 1 9 2 7 3 9 4 8 5 10 6 10 7 10 8 7 9 8 10 8

更多推荐

本文发布于:2023-08-05 13:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1432725.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最大值   Extracting   max   column   table

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!