Hello, could anyone point out how to check a empty set?
I try isempty, seems wrong
a = [1 3 2]
a =
1 3 2
K>> b = [1 3 2]
b =
1 3 2
K>> d = setdiff(a, b)
d =
Empty matrix: 1-by-0
K>> isempty(d)
ans =
Empty matrix: 1-by-0

5 Kommentare

Matt Tearle
Matt Tearle am 6 Mär. 2011
what version of MATLAB are you using? that works fine for me.
REN
REN am 6 Mär. 2011
version R2010
REN
REN am 6 Mär. 2011
run again, it works now, not sure what happend just now
a = [1 2]
a =
1 2
>> b=[1 2]
b =
1 2
>> c=setdiff(a, b)
c =
Empty matrix: 1-by-0
>> isempty(c)
ans =
1
REN
REN am 6 Mär. 2011
thanks Matt Tearle
Matt Tearle
Matt Tearle am 6 Mär. 2011
OK, never mind then

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt Tearle
Matt Tearle am 6 Mär. 2011

0 Stimmen

Problem seems to have been resolved (see above comments), but for the record:
isempty(x)
Another possibility would be
~numel(x)

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by