📄 xypm.m
字号:
% xypm.m
% Scope: This MATLAB program plots a x-y graph for the selected columns
% of the specified ASCII data file; manual scaling is available.
% Usage: xypm
% Inputs: - the name of the ASCII input data file (with extension),
% - number of the columns to be plotted,
% - the indices for the columns to be plotted,
% - title of the plot,
% - y-axis label,
% - x-axis label,
% - optional, new axes limits [xmin xmax ymin ymax].
% Outputs: - selected graphs
% Remark: The first column of the input array contains the x coordinates,
% and other columns store the y coordinates.
% 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 < 2
disp(' ');
disp('Error - XYPM; ASCII input file has less than 2 columns');
disp(' ');
return
end
x = hh(1:npt,1); % first column data is used as x-axis
yes = 'y';
answer = 'y';
temp1 = 'Enter index for the column number ';
temp2 = ' --> ';
fignr = 0;
while (strcmp(answer,yes) == 1)
fignr = fignr + 1;
% Select the columns to be plotted
disp(' ');
ngraph = input('Enter number of columns to be plotted --> ');
disp(' ');
for k = 1:ngraph
n = input([temp1 num2str(k) temp2]);
if ((n > nmax) & (n < 1))
disp(' ');
disp('Column is not in the range; check the selection ...');
temp = ['The column range is: 1 to ',num2str(nmax)];
disp(temp);
else
if (k == 1)
y = hh(:,n);
else
y = [y hh(:,n)];
end
end
end
% Execute the graphs
disp(' ');
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(y);
ymax = max(y);
figure(fignr)
plot(x,y),grid,...
title(aa), ylabel(bb),xlabel(cc)
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);
fignr = fignr + 1;
figure(fignr)
plot(x,y), grid,...
axis([xmin xmax ymin ymax]),...
title(aa), ylabel(bb), xlabel(cc)
disp(' ');
temp = input('Press <Enter> or <Return> key to continue ... ');
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
end
disp(' ');
answer = input('Do you want another plot? (y/n)[n] ','s');
end
disp(' ');
disp('End of the program XYPM ');
disp(' ');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -