Undefined function 'double' for input arguments of type 'table'. To convert to numeric, use the TABLE2ARRAY function, or extract data using dot or brace subscripting.

28 visualizaciones (últimos 30 días)
Hi,
What am I doing wrong here ?? and how would I correct it?
Code:
LSDMag_DesignPoint = ['F:\3-PIV_Experimental_Data\Calculations_TurbulentIntensity\Point_Data\Below_Outlet_LSD\Length\DesignPoint\110_outlet\Export.70m6itdj.000000.csv'];
DesignPoint = readtable(LSDMag_DesignPoint);
TurbulentFluctuation = DesignPoint(:,2);
TurbulentFluctuation_SquareRoot = (TurbulentFluctuation)^2;
Error:
Error using tabular/double (line 210)
Undefined function 'double' for input arguments of type 'table'. To convert to numeric, use the TABLE2ARRAY function, or extract data using dot or brace subscripting.
Error in ^ (line 43)
X = double(X);

Respuesta aceptada

Steven Lord
Steven Lord el 8 de Jun. de 2022
The ^ operator appears to be trying to convert its input into a double precision value, but because a table array can contain any type of data (not just numeric but also text, categorical, etc.) that conversion is not defined.
On the line immediately before you attempt to square TurbulentFluctuation you should extract the contents of the table column using curly braces not the table column itself using parentheses.
A = array2table(magic(5)) % A is a table
A = 5×5 table
Var1 Var2 Var3 Var4 Var5 ____ ____ ____ ____ ____ 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
st = A(:, 2) % st is also a table
st = 5×1 table
Var2 ____ 24 5 6 12 18
d = A{:, 2} % d is a double array
d = 5×1
24 5 6 12 18
You can square the elements of d using the .^ (element-wise power) operator [note: not the ^ (matrix power) operator] but you can't square the elements of st. That operator is not defined for table arrays.
y = d.^2 % works
y = 5×1
576 25 36 144 324
z = st.^2 % error
Operator '.^' is not supported for operands of type 'table'.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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