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 (최근 30일)
이전 댓글 표시
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
채택된 답변
Steven Lord
2022년 6월 8일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!