MATLAB Answers

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

38 views (last 30 days)
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.

  0 Comments

Sign in to comment.

Accepted Answer

Erivelton Gualter
Erivelton Gualter on 18 Nov 2019
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 Comment

Daniel McCully
Daniel McCully on 20 Nov 2019
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.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags

Products


Release

R2019a