I am executing the code below and getting the error " Undefined function 'max' for input arguments of type 'cell'" . Please help me to solve this.

function [T11,T22]=propp(t)
t=t(:)';
marge=max(t);
[s1,s]=size(t);
k=1;
T2=zeros(1,marge);
for i=1:s
T1(i)=i;
p=t(i);
T2(p)=T2(p)+1;
end
%T2=T2/s;
i=1;
while i<=marge
[p1,p2]=max(T2);
if p1==0
i=marge+1;
else
T11(i)=p2;
T22(i)=p1;
T2(p2)=0;
i=i+1;
end
end
output Undefined function 'max' for input arguments of type 'cell'. Error in propp (line 5) marge=max(t);

2 comentarios

if I make change at line 3 i.e. marge=max{t}; then the error changes to Undefined variable max.
Why are you trying to find the max of a cell array? What would you expect the output to be?

Iniciar sesión para comentar.

Respuestas (1)

Stephen23
Stephen23 el 11 de Abr. de 2015
Editada: Stephen23 el 11 de Abr. de 2015
Read the documentation for max and find the section describing the input arguments. The input array A is listed as being any of the following data-types:
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | categorical | datetime | duration
Can you see cell array listed there? And now look at the first five lines of your code:
function [T11,T22]=propp(t)
t=t(:)';
marge=max(t);
According to the error message the problem occurs on line five only when you supply t as a cell array. So if you supply t as a numeric array (one of the types listed by the documentation), then you will not get this error.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 11 de Abr. de 2015

Editada:

el 11 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by