Can't calculate mean of dataset (single column), "[F]irst argument must be numeric or logical"
1 view (last 30 days)
I am currently trying to determine the mean, median, and mode of a given dataset.
Right now, the data is in what I believe to be a string. There should be no text in said strings, only numeric data.
The dataset in question is a "string" that has only one column full of data.
I wish to, as a start, determine the mean.
When I attempt to do so, I get this error.
M = mean(Dataset)
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
I checked using
tf = istable
That the dataset was not a table.
May someone provide guidance as to what I am doing wrong? If I need to convert the dataset, how and to what?
Pravarthana P on 26 Sep 2022
Hi Austin Davis,
I understand that you are facing an issue while calculating the mean of a given dataset in ‘string’ datatype.
In order to use the ‘mean’ function the input should be in any one of the mentioned data types in this documentation link.The dataset can be converted to the required data type using "str2double" function, following which,- the mean can be calculated.
For further information kindly refer to the following documentation links:
I hope this information helps you!