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

📄 xyp3w.m

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

clear
close all

% Read the input data file

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('  ');
   error('Error  -  XYP3W; ASCII input file has less than 4 columns');
   return;
end
disp('  ');
nx = input('Enter the column number for the x-axis -->  ');
if ( (nx <= nmax) & (nx >= 1) ),
   x = hh(1:npt,nx);
else
   disp('  ');
   disp('x-axis column is not in the range; check the selection ...');
   temp = ['The column range is: 1 to  ',num2str(nmax)];
   disp(temp);
   disp('  ');
   return;
end
yes = 'y';

% Execute the first subplot

x1 = x;
disp('  ');
n = input('Enter the column number for the first subplot -->  ');
if ( (n <= nmax) & (n >= 1) ),
   y1 = hh(1:npt,n);
else
   disp('  ');
   disp('y-axis column is not in the range; check the selection ...');
   temp = ['The column range is: 1 to  ',num2str(nmax)];
   disp(temp);
   disp('  ');
   return;
end
y1mean = mean(y1);
y1std = std(y1);
y1rms = rms(y1);
temp1 = ['mean = ',num2str(y1mean)];
temp2 = ['st.dev. = ',num2str(y1std)];
temp3 = ['rms = ',num2str(y1rms)];
g = [temp1,' ;   ',temp2,' ;   ',temp3];
disp('  ');
aa1 = input('Enter title of the first subplot --> ','s');
bb1 = input('Enter y-axis label of the first subplot --> ','s');
disp('  ');
qtitle = input('Do you want x-axis label to the first subplot? (y/n)[n] ','s');
if (strcmp(qtitle,yes) == 1),
   disp('  ');
   cc1 = input('Enter x-axis label of the first subplot --> ','s');
else
   cc1 = '  ';
end
x1min = min(x1);
x1max = max(x1);
y1min = min(y1);
y1max = max(y1);
disp('   ');
disp('Place the text with statistics on the first graph; ');
temp = input('      Press <Enter> or <Return> key to start ... ');
figure(1)
subplot(311),plot(x1,y1),grid,...
title(aa1), ylabel(bb1),xlabel(cc1)
gtext(g)           %  mouse placement of the text on the first graph
disp('   ');
temp = input('Press <Enter> or <Return> key to continue ... ');

% Execute the second subplot

x2 = x;
disp('   ');
n = input('Enter the column number for the second subplot -->  ');
if ( (n <= nmax) & (n >= 1) ),
   y2 = hh(1:npt,n);
else
   disp('   ');
   disp('y-axis column is not in the range; check the selection ...');
   temp = ['The column range is: 1 to  ',num2str(nmax)];
   disp(temp);
   disp('   ');
   return;
end
y2mean = mean(y2);
y2std = std(y2);
y2rms = rms(y2);
temp1 = ['mean = ',num2str(y2mean)];
temp2 = ['st.dev. = ',num2str(y2std)];
temp3 = ['rms = ',num2str(y2rms)];
g = [temp1,' ;   ',temp2,' ;   ',temp3];
disp('   ');
qtitle = input('Do you want a title to the second subplot? (y/n)[n] ','s');
if (strcmp(qtitle,yes) == 1),
   disp('   ');
   aa2 = input('Enter title of the second subplot --> ','s');
else
   aa2 = '  ';
end
disp('   ');
bb2 = input('Enter y-axis label of the second subplot --> ','s');
disp('   ');
qtitle = input('Do you want x-axis label to the second subplot? (y/n)[n] ','s');
if (strcmp(qtitle,yes) == 1),
   disp('   ');
   cc2 = input('Enter x-axis label of the second subplot --> ','s');
else
   cc2 = '  ';
end
x2min = min(x2);
x2max = max(x2);
y2min = min(y2);
y2max = max(y2);
disp('   ');
disp('   ');
disp('Place the text with statistics on the second graph; ');
temp = input('      Press <Enter> or <Return> key to start ... ');
subplot(312),plot(x2,y2),grid,...
title(aa2), ylabel(bb2),xlabel(cc2)
gtext(g)           %  mouse placement of the text on the second graph
disp('   ');
temp = input('Press <Enter> or <Return> key to continue ... ');

% Execute the third subplot

x3 = x;
disp('   ');
n = input('Enter the column number for the third subplot -->  ');
if ( (n <= nmax) & (n >= 1) ),
   y3 = hh(1:npt,n);
else
   disp('   ');
   disp('y-axis column is not in the range; check the selection ...');
   temp = ['The column range is: 1 to  ',num2str(nmax)];
   disp(temp);
   disp('   ');
   return;
end
y3mean = mean(y3);
y3std = std(y3);
y3rms = rms(y3);
temp1 = ['mean = ',num2str(y3mean)];
temp3 = ['st.dev. = ',num2str(y3std)];
temp3 = ['rms = ',num2str(y3rms)];
g = [temp1,' ;   ',temp2,' ;   ',temp3];
disp('   ');
qtitle = input('Do you want a title to the second subplot? (y/n)[n] ','s');
if (strcmp(qtitle,yes) == 1),
   disp('   ');
   aa3 = input('Enter title of the second subplot --> ','s');
else
   aa3 = '  ';
end
disp('   ');
bb3 = input('Enter y-axis label of the third subplot --> ','s');
cc3 = input('Enter x-axis label of the third subplot --> ','s');
x3min = min(x3);
x3max = max(x3);
y3min = min(y3);
y3max = max(y3);
disp('   ');
disp('Place the text with statistics on the third graph; ');
temp = input('      Press <Enter> or <Return> key to start ... ');
subplot(313),plot(x3,y3),grid,...
title(aa3), ylabel(bb3),xlabel(cc3)
gtext(g)           %  mouse placement of the text on the third graph
disp('   ');
temp = input('Press <Enter> or <Return> key to continue ... ');
disp('   ');

%  Select manual scaling for subplots

manscaleq = input('Do you want manual scaling? (y/n)[n] ','s');
if (strcmp(manscaleq,yes) == 1),

%  Select new axes for the first subplot
 
   redo_axes_limits = 1;
   while (redo_axes_limits == 1)
      fprintf('\nCurrent limits for the first subplot are: \n');
      fprintf('   x1min = %14.7f \n',x1min);
      fprintf('   x1max = %14.7f \n',x1max);
      fprintf('   y1min = %14.7f \n',y1min);
      fprintf('   y1max = %14.7f \n',y1max);
      disp('   ');
      axes_limits = input('Enter axes limits [x1min x1max y1min y1max]:  ');
      x1min = axes_limits(1);
      x1max = axes_limits(2);
      y1min = axes_limits(3);
      y1max = axes_limits(4);
      fprintf('\nSelected limits for the first subplot are: \n');
      fprintf('   x1min = %14.7f \n',x1min);
      fprintf('   x1max = %14.7f \n',x1max);
      fprintf('   y1min = %14.7f \n',y1min);
      fprintf('   y1max = %14.7f \n',y1max);
      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 x1new;
  clear y1new;
  kk = 0;
  for k = 1:npt
      if ((x1(k) >= x1min) & (x1(k) <= x1max)),
          kk = kk + 1;
          x1new(kk) = x1(k);
          y1new(kk) = y1(k);
      end
  end 
  x1new = x1new'; 
  y1new = y1new';
  y1mean = mean(y1new);
  y1std = std(y1new);
  y1rms = rms(y1new);
  temp1 = ['mean = ',num2str(y1mean)];
  temp2 = ['st.dev. = ',num2str(y1std)];
  temp3 = ['rms = ',num2str(y1rms)];
  g = [temp1,' ;   ',temp2,' ;   ',temp3];
  disp('   ');
  disp('Place the text with statistics on the first graph; ');
  temp = input('      Press <Enter> or <Return> key to start ... ');
  figure(2)
  subplot(311),plot(x1new,y1new), grid,...
  axis([x1min x1max y1min y1max]),...
  title(aa1), ylabel(bb1), xlabel(cc1),...
  gtext(g)           %  mouse placement of the text on the first graph
  disp('   ');
  temp = input('Press <Enter> or <Return> key to continue ... ');

%  Select new axes for the second subplot
 
  redo_axes_limits = 1;
  while (redo_axes_limits == 1)
     fprintf('\nCurrent limits for the second subplot are: \n');
     fprintf('   x2min = %14.7f \n',x2min);
     fprintf('   x2max = %14.7f \n',x2max);
     fprintf('   y2min = %14.7f \n',y2min);
     fprintf('   y2max = %14.7f \n',y2max);
     disp('   ');
     axes_limits = input('Enter axes limits [x2min x2max y2min y2max]:  ');
     x2min = axes_limits(1);
     x2max = axes_limits(2);
     y2min = axes_limits(3);
     y2max = axes_limits(4);
     fprintf('\nSelected limits for the second subplot are: \n');
     fprintf('   x2min = %14.7f \n',x2min);
     fprintf('   x2max = %14.7f \n',x2max);
     fprintf('   y2min = %14.7f \n',y2min);
     fprintf('   y2max = %14.7f \n',y2max);
     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 x2new;
  clear y2new;
  kk = 0;
  for k = 1:npt
     if ((x2(k) >= x2min) & (x2(k) <= x2max)),
         kk = kk + 1;
         x2new(kk) = x2(k);
         y2new(kk) = y2(k);
     end
  end 
  x2new = x2new'; 
  y2new = y2new';
  y2mean = mean(y2new);
  y2std = std(y2new);
  y2rms = rms(y2new);
  temp1 = ['mean = ',num2str(y2mean)];
  temp2 = ['st.dev. = ',num2str(y2std)];
  temp3 = ['rms = ',num2str(y2rms)];
  g = [temp1,' ;   ',temp2,' ;   ',temp3];
  disp('   ');
  disp('Place the text with statistics on the second graph; ');
  temp = input('      Press <Enter> or <Return> key to start ... ');
  subplot(312),plot(x2new,y2new), grid,...
  axis([x2min x2max y2min y2max]),...
  title(aa2), ylabel(bb2), xlabel(cc2),...
  gtext(g)           %  mouse placement of the text on the second graph
  disp('   ');
  temp = input('Press <Enter> or <Return> key to continue ... ');

%  Select new axes for the third subplot
 
  redo_axes_limits = 1;
  while (redo_axes_limits == 1)
     fprintf('\nCurrent limits for the third subplot are: \n');
     fprintf('   x3min = %14.7f \n',x3min);
     fprintf('   x3max = %14.7f \n',x3max);
     fprintf('   y3min = %14.7f \n',y3min);
     fprintf('   y3max = %14.7f \n',y3max);
     disp('   ');
     axes_limits = input('Enter axes limits [x3min x3max y3min y3max] :  ');
     x3min = axes_limits(1);
     x3max = axes_limits(2);
     y3min = axes_limits(3);
     y3max = axes_limits(4);
     fprintf('\nSelected limits for the third subplot are: \n');
     fprintf('   x3min = %14.7f \n',x3min);
     fprintf('   x3max = %14.7f \n',x3max);
     fprintf('   y3min = %14.7f \n',y3min);
     fprintf('   y3max = %14.7f \n',y3max);
     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 x3new;
  clear y3new;
  kk = 0;
  for k = 1:npt
     if ((x3(k) >= x3min) & (x3(k) <= x3max)),
         kk = kk + 1;
         x3new(kk) = x3(k);
         y3new(kk) = y3(k);
     end
  end 
  x3new = x3new'; 
  y3new = y3new';
  y3mean = mean(y3new);
  y3std = std(y3new);
  y3rms = rms(y3new);
  temp1 = ['mean = ',num2str(y3mean)];
  temp2 = ['st.dev. = ',num2str(y3std)];
  temp3 = ['rms = ',num2str(y3rms)];
  g = [temp1,' ;   ',temp2,' ;   ',temp3];
  disp('   ');
  disp('Place the text with statistics on the third graph; ');
  temp = input('      Press <Enter> or <Return> key to start ... ');
  subplot(313),plot(x3new,y3new), grid,...
  axis([x3min x3max y3min y3max]),...
  title(aa3), ylabel(bb3), xlabel(cc3),...
  gtext(g)           %  mouse placement of the text on the third graph
  disp('   ');
  temp = input('Press <Enter> or <Return> key to continue ... ');
end
disp('   ');
disp('End of the program  XYP3W ');
disp('   ');

⌨️ 快捷键说明

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