- The number of names in that second input is, as the error message suggests, only 29, while the number of columns in PxxD6L72 is (I can only assume) 30. You have a quote and a comma reversed.
- There are duplicate names, which is an error.
- The very last input is the string 'NameObs', it should be the variable named NameObs.
Creating a dataset array
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I know this is so basic but I just can't get this to work. I have a dataset 13*30 representing power values of different frequencies in the signal. There are 30 variables, and 13 observations for each. (the Hz are 1/2 Hz bins).
I have tried the following code that I adapted from the help menu.
cow={'one';'two';'three';'four';'five';'six';'seven';'eight';'nine';'ten';'eleven';'twelve';'thirteen'} ;
NumObs=size(PxxD6L72,1);
NameObs=strcat({'cow'},num2str((1:NumObs),'%-d'));
Hz=Hz';
frequencyDL=dataset({nominal(cow),'cow'},{PxxD6L72, 'half','one','one onehalf','two','two and half','three','f','t','r','y','e','v','w','d','e','e','c','p','z','x','q','a','s','v','g','r'',y','p','u','h'},'ObsNames','NameObs');
I also have tried labeling the variables in the columns 1,1.5...15. The rows of PxxD6L7 represent the 13 different subjects(cows).
I get this error message
rror using ==> dataset.dataset>dataset.dataset at 257 Must have one variable name for each column when creating multiple variables from an array.
I don't understand because there are 30 (arbitrarily labeled hz bins- I didn't want to spend time making real labels until I got the code working). I count 30 titles so I don't understand why it says I don't have the right number of labels.
I really need to do either PCA or NMF and it would be so much easier to work with the output if I had labels.
Please help! Thanks Kim
0 Commenti
Risposta accettata
Peter Perkins
il 22 Feb 2013
There are a few things wrong here:
Hope this helps.
3 Commenti
Peter Perkins
il 22 Feb 2013
Yes. As described in the documentation, the value that follows the 'ObsNames' parameter should be a cell array of strings containing one name for each observation in the dataset array. You've created that correctly, but you have to pass that value to dataset, not the name of the workspace variable in which the names are stored.
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!