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

📄 dtplot.m

📁 很多matlab的源代码
💻 M
字号:
function dtplot(t,x,sty,clr,lin)
% DTPLOT  Plot discrete signals.
%
%        DTPLOT(X,Y,STY,CLR,LIN) Discrete plot of Y vs X.
%	 STY is point-style ( '*', '+', 'x', 'o', or 'a' for arrow)
%	 CLR is color-style ('c','m','y','r','g','b') 
%	 LIN is line-style ('-', '--', '-.', ':')
%	 STRING2 defines the type of cap placed at end of the line 
%
%        DTPLOT (with no input arguments) invokes the following example:
%
%          >>t=0:.1:3;
%          >>x=0.4+sin(pi*t);
%          >>dtplot(t,x,'a','g','--')
%          % This plots dashed green lines with arrows 


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,
 help dtplot
 disp('Strike a key to see the results')
 pause
 t=0:.1:3;
 x=0.4+sin(pi*t);
 dtplot(t,x,'a','g','--')
 return
end

v=3;
if exist('version')==5,
vr=version;
v=eval(vr(1));
end

if nargin < 5,lin='-';end
if nargin < 4,clr='r';end
if nargin < 3,sty='.';end

t=t(:)';
x=x(:)';
t1=[t;t];
x1=[x;zeros(1,length(x))];

if v < 5, 
ty1=[lin,clr];ty2=[sty,clr];ty3=['-',clr];
else,
ty1=[clr,lin];ty2=[clr,sty];ty3=[clr,'-'];
end

if sty(1)=='a';
if v >= 4,
 if ishold==0,
  plot(t1,x1,ty1);
 end
 s=axis;
else
 s=[min(t) max(t) min(x) max(x)];
end
td=.01*abs(s(2)-s(1));
ad=.03*abs(s(4)-s(3));
if v >= 4,
 ss=get(gca,'position');
 sc=0.5;
 td=td*sc/ss(3);
 ad=ad*sc/ss(4);
end
t2=t';
a1=x';
x2=sign(a1).*(abs(a1)-ad); % .05 with y
t2=[t2-td t2 t2+td t2-td]';
x2=[x2 a1 x2 x2]';
plot(t1,x1,ty1,t2,x2,ty3)
return
end


if v < 4
      plot(t1,x1,ty1,t,x,ty2)
return
end

if sty(1)=='.'
        if nargin >= 3
           plot(t1,x1,ty1,t,x,ty2,'markersize',8)
        else
           plot(t1,x1,ty1,t,x,ty2,'markersize',4)
        end
else
      plot(t1,x1,ty1,t,x,ty2)
end

⌨️ 快捷键说明

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