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)
Mostrar comentarios más antiguos
muhammad choudhry
el 8 de Jun. de 2022
Respondida: Steven Lord
el 8 de Jun. de 2022
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);
0 comentarios
Respuesta aceptada
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
st = A(:, 2) % st is also a table
d = A{:, 2} % d is a double array
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
z = st.^2 % error
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!