xstatc.m

来自「GPS software toolbox for GPS receiver de」· M 代码 · 共 72 行

M
72
字号
%                                xstatc.m
%  Scope:  This MATLAB program determines mean, standard deviation and root 
%          mean square (rms) of the elements of a specified column of the input 
%          array.
%  Usage:  xstatc
%  Inputs:  - name of the input file containing the input data array
%           - name of the output file if selected, otherwise the data are
%             displayed on screen
%           - index for the selected column
%  Outputs: - output data stored on the selected output file or displayed on 
%             the screen
%  External Matlab macros used:  rms
%  Last update:  04/19/00
%  Copyright (C) 1999-00 by  LL Consulting. All Rights Reserved.

clear
yes = 'y';
answer = 'y';

%  Enter the input data

disp('  ');
fname = input('Specify the name of the input file -->  ','s');
disp('  ');
hh = load(fname);
[nrow,ncol] = size(hh);

%  Specify the output filename if desired

answer1 = input('Do you want to save the results? (y/n)[n] --> ','s');
disp('  ');
if (strcmp(answer1,yes) == 1)
   f2 = input('Specify the output filename  -->  ','s');
   disp('  ');
else
   f2 = 1;      %  output to the screen
end

fprintf(f2,'*****  Input data file:  %s \n\n', fname);

while (strcmp(answer,yes) == 1)
   kk = input('Enter the column index -->  ');
   disp('  ');
   clear x
   if ((kk <= ncol) & (kk >= 1)),
      x = hh(1:nrow,kk);
   else
      disp('The column index is not in the range; check the selection ...');
      disp('  ');
      return
   end 

%  Determine the mean, standard deviation and rms for the selected column

   xmean = mean(x);
   xstd = std(x);
   xrms = rms(x);
   
%  Output the results
   
   fprintf(f2,'*****  Results for the column %2.0f of the input data\n\n', kk);
   fprintf(f2,'mean(x) =  %15.7f\n',xmean);
   fprintf(f2,'std(x)  =  %15.7f\n',xstd);
   fprintf(f2,'rms(x)  =  %15.7f\n\n',xrms);

   answer = input('Do you want another computation? (y/n)[n] ','s');
   disp('  ');
end

disp('End of the program  XSTATC');
disp('  ');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?