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.
19 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad choudhry
le 8 Juin 2022
Réponse apportée : Steven Lord
le 8 Juin 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 commentaires
Réponse acceptée
Steven Lord
le 8 Juin 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!