Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Help using datasetfun

$
0
0
Hello,

I have a large dataset (411,000 entries with 34 variables). My question involves using datasetfun to convert string variables into numbers. A portion of my dataset looks like this:

SAS.DocumentType(1:15)

ans =

    '27'
    '49'
    '28'
    '13'
    '32'
    '78'
    '15'
    '27'
    '35'
    '27'

All I want to do is convert these strings into numbers using str2num and datasetfun. I have tried many combinations of the following code to accomplish this:

SAS.DocumentType = datasetfun(@str2num,SAS.DocumentType);

I also seem to receive the following error message:

Undefined function 'datasetfun' for input arguments of type 'function_handle'.

I think I understand why I am receiving this error. The only way for str2num to work is if I pass it something in the {} brackets. For example, str2num(SAS.DocumentType{1}) works perfectly, but I want to do this for all 400,000 entries without using a FOR-loop. Could someone help me understand how to use datasetfun to accomplish this? Thanks.

Kevin

Viewing all articles
Browse latest Browse all 19628

Latest Images

Trending Articles