Operator '-' is not supported for operands of type 'table' even with {}

1 view (last 30 days)
I have to perform this operation in which all entities, namely d12, T1 and T2 are in table format:
d12{i,1} = norm(T1{i,3:end} - T2{i,3:end} );
In other questions the problem was solved using the right brackets but this seems not to be my case..
  7 Comments
Stephen23
Stephen23 on 20 May 2021
Edited: Stephen23 on 20 May 2021
Quite likely that T1 and/or T2 are not numeric array inputs when the function is called.
What is the complete error message that you get? This means all of the red text.
Andrea Sbaragli
Andrea Sbaragli on 20 May 2021
Since arrays stamp1 and stamp2 are in datetime format, and in report12 must coexist double and datetime values I decided to switch all inputs to table format because mixing them in arrays does not work. Moreover, before start the function T1 and T2 dimensions are as it follows:
1- T1 = jx4 double
2- T2 = kx4 double
where j and k are, of course, integers
Currently, the error seems solved but I have this one regarding mixing datetime and double in line 24 (report12(i,1)=stamp1(i,1))
The following error occurred converting from datetime to double:
Undefined function 'double' for input arguments of type 'datetime'. To convert from datetimes to numeric, first subtract off a datetime origin, then convert to numeric using the SECONDS,
MINUTES, HOURS, DAYS, or YEARS functions.
Kind of wierd considering that report12 is initialized as a table...

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!