error in 'isempty(x)' when x is in the class of dataset

Hi,
I have problems using function isempty(x) when x is in the class of dataset. For example,
>> x=randn(100,10); >> xx=dataset(x); >> isempty(xx) ??? Reference to non-existent field 'nobs'.
Error in ==> dataset.isempty at 11 t = (a.nobs == 0) (a.nvars == 0);
I think this is because when I use 'dataset', only certain fields are created, which does not include the field 'nobs'. When isempty.m tries to locate this field, the error occurs. However, I am not sure how to solve this problem. Can anyone help me with this please?
Thanks in advance.

8 件のコメント

Thomas
Thomas 2012 年 7 月 11 日
Works fine for me: What version of MATLAB are you using?
x=randn(100,10);
xx=dataset(x);
>> isempty(xx)
ans =
0
Xiu
Xiu 2012 年 7 月 11 日
I am using MATLAB 2010a
Thomas
Thomas 2012 年 7 月 11 日
I cannot test on R2010a but I can assure you it works from R2010b Sp1 onwards.. What OS are you on? Windows, Linux ,OSX?
Xiu
Xiu 2012 年 7 月 11 日
I am using Windows.
Matt Tearle
Matt Tearle 2012 年 7 月 11 日
I just tried it on 10a and it worked fine. The error seems to indicate that it doesn't recognize the nobs property. But it's using the dataset version of isempty, so it should... Very odd. Something messed up in your installation, perhaps?
Just as a sanity check, try
>> which dataset(x)
and
>> which isempty(xx)
Sean de Wolski
Sean de Wolski 2012 年 7 月 11 日
Not reproducing for me on 12a:
x=randn(100,10);
xx=dataset(x);
isempty(xx)
Xiu
Xiu 2012 年 7 月 11 日
I have figured the problem. I have additional toolbox in my matlab which contains another dataset.m file. Once I removed it, it is working perfectly fine. Thanks for all your helps.
Sean de Wolski
Sean de Wolski 2012 年 7 月 11 日
編集済み: Sean de Wolski 2012 年 7 月 11 日
Excellent!
Xiu, please write your comment as an answer and accept it to mark this question closed!

サインインしてコメントする。

 採用された回答

Xiu
Xiu 2012 年 7 月 11 日

0 投票

I have figured out this problem. I have additional toolbox installed which overlaps the function dataset. Once I have it removed, everything is working fine.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

質問済み:

Xiu
2012 年 7 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by