Filter löschen
Filter löschen

Create empty dataset and populate it row by row

8 Ansichten (letzte 30 Tage)
Mark
Mark am 24 Okt. 2011
Hi,
I'm trying to create an object of the class dataset (Stats toolbox) with a few named "columns". I want such object to initially have no rows. Then, I would like to add new rows one by one. I've tried the code below to create the dataset but I get an error. Can anyone help me with this?
Thanks in advance
P.S. I could not submit this question to the "answers" section of the Mathworks website
% Column names are 'F1' and 'F2'
myDS = dataset([],'VarNames',{'F1','F2'})
??? Error using ==> setvarnames at 23
NEWNAMES must have one name for each variable in A.
Error in ==> dataset.dataset>dataset.dataset at 383
a = setvarnames(a,varnames); % names will be modified to make them valid

Akzeptierte Antwort

Mark
Mark am 24 Okt. 2011
Fangjun Jiang 23 minutes ago
VarNames={'F1','F2'}; myDS=dataset([],[],'VarNames',VarNames)

Weitere Antworten (1)

Fangjun Jiang
Fangjun Jiang am 24 Okt. 2011
myDS =dataset({[],'F1'},{[],'F2'});
Or to see it, myDS =dataset({1,'F1'},{2,'F2'})
  3 Kommentare
Fangjun Jiang
Fangjun Jiang am 24 Okt. 2011
VarNames={'F1','F2'};
myDS=dataset([],[],'VarNames',VarNames)
Mark
Mark am 24 Okt. 2011
That worked, thanks

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by