Borrar filtros
Borrar filtros

Get error message of 'Error using max Invalid data type. First argument must be numeric or logical' when I attempt to apply max function to a column of data

43 visualizaciones (últimos 30 días)
Hi,
I'm new to MATLAB and am trying to apply the max function to the following column of data:
6.1101
5.5277
8.5186
7.0032
5.8598
8.3829
7.4764
8.5781
6.4862
5.0546
5.7107
14.164
5.734
8.4084
5.6407
5.3794
6.3654
5.1301
6.4296
7.0708
6.1891
20.27
5.4901
6.3261
5.5649
18.945
12.828
10.957
13.176
22.203
5.2524
6.5894
9.2482
5.8918
8.2111
7.9334
8.0959
5.6063
12.836
6.3534
5.4069
6.8825
11.708
5.7737
7.8247
7.0931
5.0702
5.8014
11.7
5.5416
7.5402
5.3077
7.4239
7.6031
6.3328
6.3589
6.2742
5.6397
9.3102
9.4536
8.8254
5.1793
21.279
14.908
18.959
7.2182
8.2951
10.236
5.4994
20.341
10.136
7.3345
6.0062
7.2259
5.0269
6.5479
7.5386
5.0365
10.274
5.1077
5.7292
5.1884
6.3557
9.7687
6.5159
8.5172
9.1802
6.002
5.5204
5.0594
5.7077
7.6366
5.8707
5.3054
8.2934
13.394
5.4369
with the following response:
Error using max Invalid data type. First argument must be numeric or logical.
I can't see what I'm doing wrong.
Can someone please help ?
Thanks

Respuesta aceptada

Stephen23
Stephen23 el 3 de Oct. de 2018
Editada: Stephen23 el 3 de Oct. de 2018
Your data has class table. Tables are a container class: they contain data of other classes:
The max function, like most other numeric operations, only accepts data of numeric classes:
You need to get the numeric data out of that table (container) before you can use it with a numeric operation. Getting numeric data out of a table is easy using any of the syntaxes that tables have for accessing their contents:
Probably you want something like
max(x.var)
where var is the name of the column (variable) in that table. You might find summary useful too.
  1 comentario
Angela Ebirim
Angela Ebirim el 3 de Oct. de 2018
Thank you very much!
I did the following:-
  1. extracting data from a table into an arrayx = c{:, end-1}
  2. displaying the maximum value in the array and it's index[imax, indx] = max(x)imax = 22.2030 ; indx = 30

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by