⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xypvstd.m

📁 GPS TOOLBOX包含以下内容: 1、GPS相关常量和转换因子; 2、角度变换; 3、坐标系转换: &#61656 点变换; &#61656 矩阵变换; &#61656 向量变换
💻 M
字号:
%                              xypvstd.m
%  Scope:   This MATLAB program plots a x-y graph for a selected variable and 
%           the associated envelope (standard deviation) from two specified 
%           columns of an ASCII data file when the first column data is used as
%           x-axis; manual scaling is available. 
%           In addition, the plot can incorporate statistics related to the 
%           selected graph, i.e. mean, standard deviation and root mean square 
%           rms) of the selected variable.
%  Usage:   xypvstd
%  Inputs:  - the name of the ASCII input data file (with extension),
%           - the column number for the selected variable to be plotted,
%           - the column number for the associated standard deviation,
%           - title of the plot,
%           - y-axis label,
%           - x-axis label,
%           - optional, new axes limits [xmin xmax ymin ymax].
%  Outputs: - selected graph
%  Remark:  The first column of the input array contains the  x  coordinates,
%           and other columns store the  y  coordinates. The computed/listed 
%           statistics is for the selected range of the specified graph.
%  External Matlab macros used: rms
%  Last update: 08/23/00
%  Copyright (C) 1997-00 by LL Consulting. All Rights Reserved.

clear
close all

disp('  ');
fname = input('Specify the name of the input data file (with extension) --> ','s');
hh = load(fname);
[npt,nmax] = size(hh);
if  nmax < 4
   disp('  ');
   disp('Error  -  XYPVSTD.M; ASCII input file has less than 4 columns');
   disp('  ');
   return  
end
x = hh(1:npt,1);

yes = 'y';
answer = 'y';
disp('  ');
fignr = 0;
while (strcmp(answer,yes) == 1)
   fignr = fignr + 1;
   n1 = input('Enter the variable column number -->  ');
   disp('  ');
   n2 = input('Enter the associated st. dev. column variable -->  ');
   disp('  ');
   if ( (n1<=nmax) & (n1>=2) & (n2<=nmax) & (n2>=2) )
      y = hh(1:npt,n1);
      y1 = hh(1:npt,n2);
      y2 = - y1;
      ymean = mean(y);
      ystd = std(y);
      yrms = rms(y);
      temp1 = ['mean = ',num2str(ymean)];
      temp2 = ['st.dev. = ',num2str(ystd)];
      temp3 = ['rms = ',num2str(yrms)];
      g = [temp1,' ;   ',temp2,' ;   ',temp3];
      aa = input('Enter title of the plot :  ','s');
      bb = input('Enter  Y  label :  ','s');
      cc = input('Enter  X  label :  ','s');
      xmin = min(x);
      xmax = max(x);
      ymin = min([min(y) min(y1) min(y2)]);
      ymax = max([max(y) max(y1) max(y2)]);
      disp('   ');
      disp('Place the text with statistics on the graph; ');
      temp = input('      Press <Enter> or <Return> key to start ... ');
      figure(fignr)
      plot(x,y,x,y1,'*',x,y2,'*'), ...
      title(aa), ylabel(bb),xlabel(cc),grid
      gtext(g)           %  mouse placement of the text on a graph
      disp('   ');
      temp = input('Press <Enter> or <Return> key to continue ... ');
      disp('   ');

%  Select manual scaling for both axes

      manscaleq = input('Do you want manual scaling? (y/n)[n] ','s');
      if (strcmp(manscaleq,yes) == 1),
         redo_axes_limits = 1;
         while (redo_axes_limits == 1)
            fprintf('\nCurrent limits are: \n');
            fprintf('   xmin = %14.7f \n',xmin);
            fprintf('   xmax = %14.7f \n',xmax);
            fprintf('   ymin = %14.7f \n',ymin);
            fprintf('   ymax = %14.7f \n',ymax);
            disp('  ');
            axes_limits = input('Enter axes limits [xmin xmax ymin ymax]:  ');
            xmin = axes_limits(1);
            xmax = axes_limits(2);
            ymin = axes_limits(3);
            ymax = axes_limits(4);
            fprintf('\nSelected limits are: \n');
            fprintf('   xmin = %14.7f \n',xmin);
            fprintf('   xmax = %14.7f \n',xmax);
            fprintf('   ymin = %14.7f \n',ymin);
            fprintf('   ymax = %14.7f \n',ymax);
            disp('  ');
            newlimq = input('Do you want to change axes limits? (y/n)[n] ','s');
            if (strcmp(newlimq,yes) == 0),
               redo_axes_limits = 0;
            end
         end
         clear xnew;
         clear ynew;
         kk = 0;
         for k = 1:npt
            if ((x(k) >= xmin) & (x(k) <= xmax)),
               kk = kk + 1;
               xnew(kk) = x(k);
               ynew(kk) = y(k);
            end
         end 
         xnew = xnew'; 
         ynew = ynew';
         ymean = mean(ynew);
         ystd = std(ynew);
         yrms = rms(ynew);
         temp1 = ['mean = ',num2str(ymean)];
         temp2 = ['st.dev. = ',num2str(ystd)];
         temp3 = ['rms = ',num2str(yrms)];
         g = [temp1,' ;   ',temp2,' ;   ',temp3];
         disp('   ');
         disp('Place the text with statistics on the graph; ');
         temp = input('      Press <Enter> or <Return> key to start ... ');
         fignr = fignr + 1;
         figure(fignr)
         plot(x,y,x,y1,'*',x,y2,'*'),grid,...
         axis([xmin xmax ymin ymax]),...
         title(aa), ylabel(bb), xlabel(cc),...
         gtext(g)           %  mouse placement of the text on a graph
         disp('   ');
         temp = input('Press <Enter> or <Return> key to continue ... ');
      end
   else
      disp('Column(s) is(are) not in the range; check the selection ...');
      temp = ['The column range is: 1 to  ',num2str(nmax)];
      disp(temp);
   end
   disp('  ');
   answer = input('Do you want another plot? (y/n)[n] ','s');
   disp('  ');
end
disp('End of the program  XYPVSTD ');
disp('  ');

⌨️ 快捷键说明

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