Hello,
would you please give me an example of use of dataset? I am used to structures now, but I think that dataset could be easier to handle for my purposes. Say that I would like to see how dataset works having to import a simple txt data like:
a b c
1 2 3
4 5 6
7 8 9
Thanks for your example. Chiara

답변 (3개)

Matt Tearle
Matt Tearle 2011년 4월 12일

1 개 추천

x = dataset('file','simple.txt','delimiter',' ')
x.Properties.VarNames
x.a
plot(x.a,x.b,'o-')
the cyclist
the cyclist 2011년 4월 12일

0 개 추천

Have you read the example in the documentation?
>> doc dataset
Chiara Modenese
Chiara Modenese 2011년 4월 12일

0 개 추천

Thanks. Could you tell if it is also possible to create an array of dataset arrays? Having several files to deal with, I need to be able to write loops easily.

댓글 수: 3

Matt Tearle
Matt Tearle 2011년 4월 13일
Not exactly. Your options would be to make a cell array of dataset arrays, or to concatenate dataset arrays in some way.
If you're looping over data from multiple files, I'm guessing that you have files with the same formatting? In that case, your dataset arrays would have the same variables. If you want to merge the data sets, then you can just do a regular vertical concatenation (z = [x;y]). But if you want to keep them distinct (eg to compare the same variable from two different data sets), the easiest would probably be to make a cell array:
z = cell(n,1);
for k = 1:n
z{k} = dataset(...);
end
Then, later you can do stuff like
plot(z{1}.b,z{2}.b,'o-')
If your data is split up across multiple files, you can merge dataset arrays using the join method.
Chiara Modenese
Chiara Modenese 2011년 4월 13일
Ok. I see the point, and in the end it turns out to be not so different from the use I do of structures. I was trying to make some comparisons between dataset and structures, to see pros and cons. In my case, I have data files with also different formatting so I may have different variables. Your suggestion is good though, thanks.
Oleg Komarov
Oleg Komarov 2011년 4월 13일
In general a DBMS is much better than MATLAB at managing data (dataset arrays try to emulate the functionalities of a database). In the long run I would invest time to learn SQL to manage data and interface it with MATLAB whenever computational complexity arises.
In my experience I started using only MATLAB and ended up executing 80% of descriptive statistical analysis with SQL Server!

댓글을 달려면 로그인하십시오.

카테고리

태그

질문:

2011년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by