Undefined function 'abs' for input arguments of type 'cell'.

12 次查看(过去 30 天)
function c = test(A)
r=abs(A(2,2));
disp(r);
end
I'm trying to take the absolute value of a specific cell but i get this error.
Undefined function 'abs' for input arguments of type 'cell'.
Error in test (line 2)
r=abs(A(2,2));
What is going on that I can't see?
A is also a matrix with dimensions of at least 2x2.

采纳的回答

Erivelton Gualter
Erivelton Gualter 2019-11-18
It is saying A is a cell type. In order to check it, run the following code:
class(A)
If this is the case, the following should work:
function c = test(A)
r=abs([A{2,2}]);
disp(r);
end
  1 个评论
Daniel McCully
Daniel McCully 2019-11-20
Yah I did not realize there was a difference between { } and [ ] when inputting matrices. So my code was correct I was just inputting values wrong.

请先登录,再进行评论。

更多回答(0 个)

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by