How do I find the mean and standard deviation of each column for this data?
조회 수: 9 (최근 30일)
이전 댓글 표시
what code would produce a table of the mean and standard deviation
댓글 수: 2
Ameer Hamza
2020년 11월 9일
Several of your tables have string data types. What do you want to do with those columns?
답변 (2개)
Ameer Hamza
2020년 11월 9일
Try this
data = readtable('banking_data.csv');
idx = cellfun(@(x) isa(x, 'double'), table2cell(data(1, :)));
data = data{:,idx};
data_mean = mean(data);
data_std = std(data);
댓글 수: 0
Steven Lord
2020년 11월 9일
If you've read this data into a table array you can extract those variables in the table that contain numeric data then use varfun to perform an operation on each variable in the extracted table.
% Sample table
load patients
patients = table(LastName,Gender,Age,Height,Weight,Smoker,Systolic,Diastolic);
head(patients)
% Use vartype to extract just numeric data (Age, Height, Weight, Systolic, Diastolic)
numericData = patients(:, vartype('numeric'));
head(numericData) % note no LastName, Gender, or Smoker variables
% Take the mean and std of each variable in the smaller table numericData
meanData = varfun(@mean, numericData)
stdData = varfun(@std, numericData)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!