中国海洋大学MATLAB期末复习2014 - 答案

2026/1/21 17:55:24

% Initialize sums

sum_x = 0; sum_x2 = 0;

% Get the number of points to input. n = input('Enter number of points: ');

% Check to see if we have enough input data. if n < 2 % Insufficient data

disp ('At least 2 values must be entered.');

else % we will have enough data, so let's get it. % Loop to read input values. for ii = 1:n

% Read in next value x = input('Enter value: '); % Accumulate sums. sum_x = sum_x + x; sum_x2 = sum_x2 + x^2; end

% Now calculate statistics. x_bar = sum_x / n;

std_dev = sqrt((n * sum_x2 - sum_x^2) / (n * (n - 1))); % Tell user.

fprintf('The mean of this data set is: %f\\n', x_bar); fprintf('The standard deviation is: %f\\n', std_dev); fprintf('The number of data points is: %f\\n', n); end


中国海洋大学MATLAB期末复习2014 - 答案.doc 将本文的Word文档下载到电脑
搜索更多关于: 中国海洋大学MATLAB期末复习2014 - 答案 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219