📄 e424.asv
字号:
% Script file: E424.m
% Purpose:
% To calculate the input datas' arithmetic mean and
% the geometric mean.The datas was given by user.
% Record of Revision
% Date Programmer Description
% ============ ================= =================
% 13/06/08 ZMW Original Code
% Define Variables
% n ----------the number of input data
% gave ----------geometric mean
% aave ----------arithmetic mean
% sum -----------the sum of input datas
% mul -----------the multiple of input datas
% ii ---------- index
% x ---------- the data array
disp('The programme is used to calculate the arithmetic mean and geometric mean');
% n=input('Enter the number of input data:');
ii=1;
sum=0;
mul=1;
while ii<=n
x(ii)=input('Enter x dataset:');
ii=ii+1;
if x(ii)<0
break;
end
end
for ii=1:n
sum=sum+x(ii);
mul=mul*x(ii);
end
gave=mul^(1/n);
aave=sum/n;
fprintf('the arithemtic mean is : %f\n',aave);
fprintf('the geometric mean is : %f\n',gave);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -