function [xave, xstd, xavestd] = func(x) % 计算样本均值 xave = mean(x); % 计算单次测量的实验标准差 xstd = std(x); % 计算均值的实验标准差 xavestd = xstd / sqrt(length(x)); end

% 调用自己编写的程序 x = [3.2, 3.4, 3.5, 3.3, 3.6, 3.1, 3.2, 3.5, 3.4, 3.3]; [xave, xstd, xavestd] = func(x);

% 输出结果 disp(['样本均值:', num2str(xave)]); disp(['单次测量的实验标准差:', num2str(xstd)]); disp(['均值的实验标准差:', num2str(xavestd)]);

结果: 样本均值:3.35 单次测量的实验标准差:0.161107315568707 均值的实验标准差:0.0509452075960265


原文地址: https://www.cveoy.top/t/topic/nJZp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录