Find the maximum value of a column in a table

113 次查看(过去 30 天)
I have a spreadsheet that is read into a Matlab table. I need to get the maximum value in column 1. I thought the following would work, but it keeps throwing up an error.
MaxExpTime = max(A(:1));

回答(1 个)

Dave B
Dave B 2021-10-29
编辑:Dave B 2021-10-29
The problem here is that A(:,1) returns a table not the values in the table. You can retrieve the values with A.(1) or A{:,1} but better practice is to use variable names (e.g. A.Var1) with a table:
A=table(rand(10,1))
A = 10×1 table
Var1 _______ 0.92076 0.69648 0.27894 0.40647 0.90258 0.21383 0.17593 0.8362 0.23215 0.95136
max(A.(1))
ans = 0.9514
max(A{:,1})
ans = 0.9514
max(A.Var1)
ans = 0.9514

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by