if I make change at line 3 i.e. marge=max{t}; then the error changes to Undefined variable max.
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.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
James Tursa
am 11 Apr. 2015
Why are you trying to find the max of a cell array? What would you expect the output to be?
Antworten (1)
Stephen23
am 11 Apr. 2015
Bearbeitet: Stephen23
am 11 Apr. 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.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!